1、原文件:
2、期望效果
3、SAS程序
proc import out=test
datafile="C:\Users\hp\test"
dbms=excel replace;quit;
options validvarname=any;
proc sql;
create table tmp1 as select distinct
*,
prxmatch("/北京|东城|西城|崇文|宣武|朝阳|丰台|石景山|海淀|门头沟|房山|通州|顺义|昌平|大兴|怀柔|平谷|密云|延庆/",place) as 北京,
prxmatch("/天津|和平|河东|河西|南开|河北|红桥|塘沽|汉沽|大港|东丽|西青|津南|北辰|武清|宝坻|宁河|静海|蓟县/",place) as 天津,
prxmatch("/南京|玄武|白下|秦淮|建邺|鼓楼|下关|浦口|栖霞|雨花台|江宁|六合|溧水|高淳/",place) as 南京,
prxmatch("/无锡|崇安|南长|北塘|滨湖|锡山|惠山|江阴|宜兴/",place) as 无锡,
prxmatch("/徐州|云龙|九里|贾汪|泉山|新沂|邳州|丰县|沛县|铜山|睢宁/",place) as 徐州,
prxmatch("/常州|钟楼|天宁|戚墅堰|新北|武进|溧阳|金坛/",place) as 常州,
prxmatch("/苏州|金阊|沧浪|平江|虎丘|吴中|相城|常熟|张家港|昆山|吴江|太仓/",place) as 苏州
from test as a ;
quit;
4、实际结果