I can create multiple data sets using the following way:
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;
I tried to do this within a macro, but each time the macro would overwrite the other such that only the last data set would remain and it wouldn't create multiple data sets. How can I accomplish this task within a macro?
Added from comments:
%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);
And so on.