我需要创建一个zipcodes变量,它结合了字符串变量" zip"在每个城市的邮政编码的连锁列表中。这就是我到目前为止所拥有的:
data work.zip (drop=estimated_population zip);
set work.clean;
by state primary_city;
length zipcodes $200;
retain zipcodes;
if first.primary_city then do;
estcitpop=0;
zipcodes= zip;
end;
else
zipcodes=cats(zipcodes, ',', zip);
estcitpop+estimated_population;
if last.primary_city;
run;
这让我得到了正确的结果,但还有更好的方法吗?
Zips是字符值,需要保持这种状态。例如,如果对于休斯敦市,你有拉链12345,11345,11145和11115,我需要拉链码来阅读" 12345,11345,11145,11115"。
答案 0 :(得分:1)
看起来很好。我会使用data work.zip ;
do until (last.primary_city);
set work.clean;
by state primary_city;
length zipcodes $200;
zipcodes=catx(',',zipcodes, zip);
estcitpop=sum(estcitpop,estimated_population);
end;
drop estimated_population zip;
run;
函数和DOW循环来使其更简单。
WebDriverWait