Reputation: 41
I'm trying to call macros at run-time based on the inputs provided.
the macro execution step will be like below
%(¯ovariable);
whereas the value of the macrovariable will be provided at run time.
is this possible or is there any way of acheiving this?
Upvotes: 4
Views: 99
Reputation: 12465
Easy.
%macro test(a);
%put Test says &a;
%mend;
%let mymacro = test;
%&mymacro(Hello World);
Returns
8239 %macro test(a);
8240 %put Test says &a;
8241 %mend;
8242
8243 %let mymacro = test;
8244
8245 %&mymacro(Hello World);
Test says Hello World
Upvotes: 5
Reputation: 1068
There might be another way, but you could use CALL EXECUTE
after a null data step like:
data _null_;
CodeToRun = cats('%',"&MyMacroName");
Call Execute (CodeToRun);
run;
Some background and examples on CALL EXECUTE here.
Upvotes: 1