Does this the job for you?
data have;
do i= 2 to 14,16,17,41;
_TEMG001=i; ma_pd_ind='PD'; month=7;output;
_TEMG001=i; ma_pd_ind='xx'; month=7;output;
_TEMG001=i; ma_pd_ind='PD'; month=10;output;
end;
run;
proc sql noprint;
select distinct _TEMG001, cats('work.temp',_TEMG001), cats('when(',_TEMG001,') output temp',_TEMG001,';')
into :IndList separated by ' ', :OutDS separated by ' ', :SelectDs separated by ' '
from have
order by _TEMG001;
quit;
%put OutDs =%bquote(&OutDs);
%put SelectDs=%bquote(&SelectDs);
data &OutDS;
set have;
where ma_pd_ind='PD' and month<10;
select (_TEMG001);
&SelectDs
otherwise;
end;
run;
... View more