1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Example 3: Using the %MACRO Statement with the PARMBUFF Option
The macro PRINTZ uses the PARMBUFF option to enable you to input a different number of arguments each time you invoke it:
%macro printz/parmbuff;
%let num=1;
%let dsname=%scan(&syspbuff,&num);
%do %while(&dsname ne);
proc print data=&dsname;
run;
%let num=%eval(&num+1);
%let dsname=%scan(&syspbuff,&num);
%end;
%mend printz;
This invocation of PRINTZ contains four parameter values, PURPLE , RED , BLUE , and TEAL although the macro definition does not contain any individual parameters:
%printz(purple,red,blue,teal)
As a result, SAS receives these statements:
PROC PRINT DATA=PURPLE;
RUN;
PROC PRINT DATA=RED;
RUN;
PROC PRINT DATA=BLUE;
RUN;
PROC PRINT DATA=TEAL;
RUN; |
Partager