BookmarkSubscribeRSS Feed
pawandh
Fluorite | Level 6


%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.

2 REPLIES 2
JoshB
Quartz | Level 8

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)

 

 

Jagadishkatam
Amethyst | Level 16
please try to call the macro as %nn(%nrstr(one,two,three))
Thanks,
Jag

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1298 views
  • 0 likes
  • 3 in conversation