I updated the code to use FINDW() to make it easier, try it now.
The concept is the same, pass the list of values in one parameter and write your macro to use the list. You can work out the details or what method works best for your situation.
For example you might just want to use the space delimited value in the generated code:
%mymacro(varlist);
proc print data=sashelp.class;
var &varlist;
run;
%mend;
%mymacro(name age sex)
or use a %DO loop;
%mymacro(dslist);
%local i dsn ;
%do i=1 %to %sysfunc(countw(&dslist,%str( )));
%let dsn=%scan(&dslist,%str( ));
proc print data=&dsn;
run;
%mend;
%mymacro(sashelp.class sashelp.cars(obs=10))
Or use some other delimiter besides space, like | or ^ that cannot appear in the actual values being passed. I would avoid using comma as that will mean you need to use macro quoting to avoid SAS thinking you mean values for multiple parameters.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.