Is your syntax the same for each state/year/etc.? So you've got something like proc means data=TX_DATA_2005; var OUTCOME1 OUTCOME2; outout out=TX_OUTPUT_2005 mean=; run; and you want to alter "TX" and "2005" ? You may be able to do this without a macro, depending on your analysis. Many analyses can be done with BY or CLASS to handle the the states. For example, if you have one dataset MYDATA, and it has STATE and YEAR as variable: proc means data=MYDATA; class state year; types state*year; var OUTCOME1 OUTCOME2; output out=MYDATAOUT mean=; run; That would work much more easily than a macro, and BY STATE YEAR; would work as well. If that doesn't work for some reason (and I strongly encourage trying that first, it's much more maintainable), this is roughly how you'd do things: %macro myAnalysis(State=,year=); proc means data=&state._DATA_&year.; var OUTCOME1 OUTCOME2; outout out=&state._OUTPUT_&year. mean=; title "Analysis of &state for &year."; run; %mend myAnalysis; proc sql; select distinct cats('%myAnalysis(state=',state,',year=',year,')') into :runlist separated by ' ' from styrdataset; quit; &runlist. That assumes that STYRDATASET has the various possible state/years in it in some fashion (this might be a source dataset, or an artificially created one, or even an excel file you import that someone who wants an analysis run for a state/year set fills out). &runlist. calls the macro %myAnalysis.
... View more