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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 2238 views
  • 5 likes
  • 4 in conversation