%macro nn(dt);
%do i=1 %to 3;
%let x=%sysfunc(scan("&dt",&i,',');
%put &x;
data t;
set &x;
run;
proc print;run;
%end;
%mend;
%nn(one,two,three);
want to print all the three data sets,getting error that More positional parameters found than defined.
You are passing three parameter (one , two , and three), while only defining one parameter to be passed (dt).
You can either quote what you are trying to pass to the macro
%nn(%quote(one,two,three))
Or, you can modify the macro to include a space as a delimiter in your scan function and pass the parameter separated by spaces.
%macro nn(dt);
%do i=1 %to 3;
%let x=%sysfunc(scan(&dt,&i,', '));
%put &x;
data t;
set &x;
run;
proc print;run;
%end;
%mend;
%nn(one two three)
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.