0
設置宏之內我可以用下面的方式來創建多個數據集:創建數據在SAS
data D3RGDPX (drop=BasePeriod BaseYear Forecast10Year)
D3GDPX (drop=BasePeriod BaseYear Forecast10Year)
D3BFIX (drop=BasePeriod BaseYear Forecast10Year)
D3CPAT (drop=BasePeriod BaseYear Forecast10Year)
D3IP (drop=BasePeriod BaseYear Forecast10Year)
D3TPHS (drop=BasePeriod BaseYear Forecast10Year)
D3PPI (drop=BasePeriod BaseYear Forecast10Year)
D3CPI (drop=BasePeriod BaseYear Forecast10Year)
D3UNPR (drop=BasePeriod BaseYear Forecast10Year)
D3WMFG (drop=BasePeriod BaseYear Forecast10Year)
D3RTTR (drop=BasePeriod BaseYear Forecast10Year)
D3AUTODF (drop=BasePeriod BaseYear Forecast10Year)
D3SPIF (drop=BasePeriod BaseYear Forecast10Year);
set my.data;
if Type='RGDPX' then output D3RGDPX;
else if Type='GDPX' then output D3GDPX;
else if Type='BFIX' then output D3BFIX;
else if Type='CPAT' then output D3CPAT;
else if Type='IP' then output D3IP;
else if Type='TPHS' then output D3TPHS;
else if Type='PPI' then output D3PPI;
else if Type='CPI' then output D3CPI;
else if Type='UNPR' then output D3UNPR;
else if Type='WMFG' then output D3WMFG;
else if Type='RTTR' then output D3RTTR;
else if Type='AUTODF' then output D3AUTODF;
else if Type='SPIF' then output D3SPIF;
run;
,我打算給宏內做到這一點,但每次宏將覆蓋其他使得只有最後的數據集將保留,並且不會創建多個數據集。我如何在宏中完成這項任務?
新增自評:
%macro new (data=, set=, Type=);
data &data (drop=BasePeriod BaseYear Forecast10Year);
set my.data;
if Type = "&Type" then output &data;
run;
%mend new;
%new (data =D3RGDPX, Type = RGDPX);
%new (data=D3GDPX, Type=GDPX);
等。
請向我們展示您迄今嘗試使用的代碼。 – DomPazz
%macro new(data =,set =,Type =); data&data(drop = BasePeriod BaseYear Forecast10Year); set my.data; if Type =「&Type」then then &data; run; %修補新; %new(data = D3RGDPX,Type = RGDPX); %new(data = D3GDPX,Type = GDPX); 依此類推。 – user2916331
我把你的代碼放到問題中 - 在那裏讀起來更容易。 – DomPazz