Running SAS Macro

I am trying to call macros at runtime based on the provided data.

macro execution step will look below

% (& macro variable);

whereas the value of the macro virus will be provided at runtime.

Is this possible or is there any way to achieve this?

+4
source share
2 answers

Easily.

%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
+5
source

There may be another way, but you can use CALL EXECUTEdata after the zero step, for example:

data _null_;
    CodeToRun = cats('%',"&MyMacroName");
    Call Execute (CodeToRun);
run;

Some examples and examples on CALL EXECUTE here .

+1
source

Source: https://habr.com/ru/post/1526837/


All Articles