I hope you like the simplicity of this approach. The PROC SQL creates 2 macro variables that you can use in your datastep. No Macro or Maco looping required. Take out the INTO section of the PROC SQL to see what its creating in the macro variable data SAMPLE; input month data; /* Stored a Number */ cards; 8 1111222233334444 2 2222333344445555 3 598758 5 598758321654 6 987654 8 598758 8 00005987581212 2 2371287598758222 ;run; proc sql; select "DATASETNAME"!!put(TABLE,2.-L) ,"if MONTH = "!!put(MONTH,2.-L)!!" then output DATASETNAME"!!put(TABLE,2.-L) into :DATALINE separated by ' ' ,:SPLIT separated by ';' from ( select monotonic() as TABLE ,month from (select distinct month from SAMPLE)) ;quit; data &DATALINE; set SAMPLE; &SPLIT; run;
... View more