/***************************************************************************************************************** SAS file name: parmbuff.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to use the Parmbuff Option in the %Macro Statement Author: Peter Clemmensen Creation Date: This program supports the blog post "Explore the Parmbuff Option in the SAS Macro Language" on SASnrd.com *****************************************************************************************************************/ /* A simple parmbuff test */ %macro test / parmbuff; %put &syspbuff; %mend test; %doit(abc); /* A simple sum macro function */ %macro sumthem / parmbuff; %local i s j; %let i = 1; %let s = 0; %do %while (%qscan(&syspbuff, &i, %str(,%(%))) ne %str()); %let j = %qscan(&syspbuff, &i, %str(,%(%))); %let s = %sysevalf(&s + &j); %let i = %eval(&i + 1); %end; &s %mend sumthem; %put The sum is %sumthem(1,2,3); /* An example from the documentation */ %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; %printz(purple,red,blue,teal)