Dear All, Suppose that I have the following addresses (in Chinese),
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str144 t_addr2
"彰化市曉陽路301巷6弄10號"                                                             
"台中市台灣大道三段251號9樓"                                                         
"500 彰化縣 彰化市 長順街141巷14號-假日配送無電鈴到貨請打0973221508感謝"
"302 新竹縣竹北市文興路一段372號"                                                   
"900 屏東縣 屏東市 公勇路83號8樓之1"                                                
end
I uses the code
Code:
gen zipcode = ustrregexs(1) if ustrregexm(t_addr2,"^([0-9]*)(.*市|.*縣)?(.*市|.*區)?")
gen city = ustrregexs(2) if ustrregexm(t_addr2,"^([0-9]*)(.*市|.*縣)?(.*市|.*區)?")
gen city2 = ustrregexs(3) if ustrregexm(t_addr2,"^([0-9]*)(.*市|.*縣)?(.*市|.*區)?")
with results
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str13 zipcode str81 city str91 city2
""    "彰化市"            ""         
""    "台北市"            "內湖區"
"500" " 彰化縣 彰化市" ""         
"302" " 新竹縣竹北市"  ""         
"900" " 屏東縣 屏東市" ""         
end
However, the desired results are
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str13 zipcode str81 city str91 city2
""    "彰化市"  ""         
""    "台北市"  "內湖區"
"500" " 彰化縣" "彰化市"
"302" " 新竹縣" "竹北市"
"900" " 屏東縣" "屏東市"
end
Any suggestions? Thanks.