Two things: first if you want to use named-style parameters add an = after the name, second: because the underscore is a valid char in variable names, you need to add separating periods. %macro name_1 (mth=, yr=); proc sort data=&mth._&yr._ by bank_number account_number ; run; %mend; You can increase the level of automation (untested code): data _null_; do year = 2010 to 2012; do month = 1 to 12; text_month = put(mdy(month, 1, year), MONNAME3.); dataset = cats(text_month, '_', year, '_'); if exist(dataset) then do; call execute(cats('%name_1(mty=', text_month, ', yr=', year, ');')); end; end; end; run;
... View more