需求:有两张表,一张名为‘riskmap’是全国各省数据,另一张名为‘location’是地区机构表(三个字段,一是省名location,二是省号location_code(顺序号),三是省下面地市名locaiton_son),现在需要生成各地市的数据,完全复制其所属省份的数据,以下SAS程序请高手看哪里有问题??
%macro change();
%let a=1;
%do %until(&a.>22);
proc sql noprint;
select distinct location
into:loc
from location
where location_code=&a.;
quit;
data locson;
set location(where=(location=&loc.));
quit;
data _null_;
set locson nobs=b;
%let c=b;
quit;
data risk;
set riskmap(where=(location=&loc.));
quit;
%let d=1;
%do %until(&d.>&c.);
proc sql noprint;
select location_son
into:lson
from locson
where _n_=&d.;
quit;
data map&a.&d.;
set risk;
location=symget("lson");
quit;
proc append base=null data=map&a.&d.;
quit;
&d+1;
%end;
&a+1;
%end;
%mend change;
%change;