Since the %DO isn't allowed in open code you need a macro. The example below allows parameters to change the start and end year. It could be made more generic with a parameter for the base of the data set name as well. Pay attention to the positions of semicolons!. %macro dname(syr=,eyr=); data all; set %do yr=&syr %to &eyr; %do m=1 %to 12; %let m2= %sysfunc(putn(&m,z2.));/* this is to get the leading zeros*/ /* the %DO will not increment leading 0*/ data&yr.&m2 %end; %end; ;/* to close set statement*/ /* other code*/ run; %mend; /* how to use*/ %dname(syr=2009, eyr=2011);
... View more