Alph
Alph

Reputation: 391

macro references execution in call execute

SAS documentation says the macro references in call execute are executed immediately. Does this code exemplify it?

 %let var = abc;

 data _null_;
   call execute ('&var');
 run;

Upvotes: 0

Views: 42

Answers (1)

Tom
Tom

Reputation: 51621

Sort of. Here is a more complete example using value of the macro variable that is actual executable SAS code.

data _null_;
  call symputx('var','data;run;');
run;

%put var= %superq(var);

data _null_;
  call execute ('&var');
run;

You can see in the SAS log that the code that CALL EXECUTE() actually pushed onto the stack to run is the VALUE of the macro variable even though the single quotes would prevent the macro variable from expanding during the data _null_ step that is using the CALL EXECUTE() statement.

NOTE: CALL EXECUTE generated line.
1    + data;run;

Upvotes: 2

Related Questions