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

Hi All

I am not sure whether it was answered before in this community. (Sorry for duplicating). The question is:

If I have a macro with some parameters like this:

%Macro have( A = , B =, C = , D 😃

Program goes here...

%Mend

Now, I want to execute this program many times in the program with different set of parameters

%Have ( A = 1 , B = 2 , C = 3, D = 4);

%Have ( A =  3, B = 3 , C =9, D = 6);

.....................................................

......................................................

This look litte ugly to me as repeating a macro progam. Are there other ways where we can produce the same results but looks nice.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You can use a dataset to hold these parameter, then call execute them.

data x;

input a b c d;

cards;

1 2 3 4

3 3 9 6

;

run;

data _null_;

set x;

call execute( '%have(' || a || ',' || ....................... );run;

View solution in original post

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

Is this better?

%Macro have( A , B , C , D )

Program goes here...

%Mend

Now, I want to execute this program many times in the program with different set of parameters

%Have ( 1 ,  2 ,  3, 4)

%Have (3,  3 , 9,  6)

...................................................

Ksharp
Super User

You can use a dataset to hold these parameter, then call execute them.

data x;

input a b c d;

cards;

1 2 3 4

3 3 9 6

;

run;

data _null_;

set x;

call execute( '%have(' || a || ',' || ....................... );run;

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