BookmarkSubscribeRSS Feed
pawandh
Fluorite | Level 6


%macro ab(x);

proc print data=test1 ;where rating in(&x);run;

%mend;
%ab(2,3,4)

 

here i'm getting error that more positional parameters found but if i write

proc print data=test1 ;where rating in(2,3,4);run;

i'm getting the desired output.

 

&x also doing the same then y error is cmng?

I think after resolving macro variable to (2,3,4) it should work like a normal sas program.

.

Please explain how the macro processor is processing these values.

 

 

4 REPLIES 4
LinusH
Tourmaline | Level 20
The commas between the values make the macro compiler treat them as separate parameters.
In your case the simplest is to skip the commas since IN () can handle blanks as a list separator.
Data never sleeps
pawandh
Fluorite | Level 6

if i write 

proc print data=test;

where rating in (2,3,4);run;

i get the desired output.

But instead of 2,3,4 if i write a macro variable which has the sam values(2,3,4) then it is not showing the desired result??

 

macro resolving to 2,3,4 only.so it should print the observations.

Jagadishkatam
Amethyst | Level 16
Hope you tried %ab(%str(2,3,4))
Thanks,
Jag
Jagadishkatam
Amethyst | Level 16
Please mask the commas using the %str while compilation and you could avoid the error. Try calling the macro as below

%ab(%str(2,3,4))
Thanks,
Jag

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 735 views
  • 0 likes
  • 3 in conversation