BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kumarK
Quartz | Level 8

i have a macro it will take input as a country and will give its population.

Then i have another table list of all countries. I want to pass all these countries to that macro.

I tried below way i declared all the countries in a global variable and passed that variable

% let countries=india nepal......;

This is not a efficient way. how can i pass all the values of another table in to that macro. Please throw some inputs.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Yeah.

%macro mymac(a);

proc print data=test;

where name = "&a";

run;

%mend;

View solution in original post

3 REPLIES 3
Ksharp
Super User

proc sort data=have(keep=country) out=country nodupkey;by country;run;

data _null_;

set country;

call execute('%mymacro(country=' ||country|| ')' );

run;

Xia Keshan

kumarK
Quartz | Level 8

Thanks for your reply Xia Keshan,


I am getting one error. Is there anything i am missing in below code?

data test;

set sashelp.class;

run;

data name_list;

input names$;

cards;

Alfred

Henry

John

Ronald

run;

%macro mymac(a);

proc print data=test;

where name = &a;

run;

%mend;

data _null_;

set name_list;

call execute('%mymac('||names||')');

run;

Ksharp
Super User

Yeah.

%macro mymac(a);

proc print data=test;

where name = "&a";

run;

%mend;

sas-innovate-2024.png

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.

 

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.

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
  • 3 replies
  • 1138 views
  • 3 likes
  • 2 in conversation