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


I need to run the same macro CT 50 times changing just one of the several parameters. A, B, C...... are 50 variables that need to be replaced in the call macro.

%CT(param1=data, param2=inv, param3=A);

%CT(param1=data, param2=inv, param3=B);

%CT(param1=data, param2=inv, param3=C);

.....

1 ACCEPTED SOLUTION

Accepted Solutions
sasjourney
Calcite | Level 5

I like Barry's 1st answer Smiley Happy  and below is how you would do for his second suggestion.

get the list of variables that needs to be passed to the macro and send them all to a macro variable separating them by a special character, say LIST for example:

the macro variable LIST would be like this A*B*C*D*............*Z

now loop it through all the parameters

%do i=1 %to 50;

     %let param=%scan(&list,&i,'*');

     %CT(param1=data, param2=inv, param3=&param);

%end;


hope this helps.

View solution in original post

3 REPLIES 3
twocanbazza
Quartz | Level 8

Copy and paste works well Smiley Wink

or consider using a macro do / while loop


sasjourney
Calcite | Level 5

I like Barry's 1st answer Smiley Happy  and below is how you would do for his second suggestion.

get the list of variables that needs to be passed to the macro and send them all to a macro variable separating them by a special character, say LIST for example:

the macro variable LIST would be like this A*B*C*D*............*Z

now loop it through all the parameters

%do i=1 %to 50;

     %let param=%scan(&list,&i,'*');

     %CT(param1=data, param2=inv, param3=&param);

%end;


hope this helps.

LinusH
Tourmaline | Level 20

You can have you parameters stored in a SAS table, and call the macro by using call execute instead.

Data never sleeps

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
  • 1350 views
  • 5 likes
  • 4 in conversation