Reputation: 17077
I have some legacy SAS code that defines a macro inside a data step. How does this work? Does the macro get compiled for every iteration of DATA step?
data test;
set temp;
%macro cal_sum(iput);
%let a=&input.;
%mend;
REPORTING_DATE = &PROCDATE.;
call execute('%cal_sum(testval)');
run;
Upvotes: 0
Views: 973
Reputation: 27498
The macro code, in this case a macro definition, gets fully resolved before the data step is compiled and run by the SAS executor.
So no, the macro is not compiled for every iteration of the DATA step.
Also, as you my be aware, a macro call coded inside a data step is not invoked for every iteration, however, whatever source code the macro call emitted will be.
Upvotes: 1
Reputation: 12691
No. In this case, the macro is compiled before the data step executes. There are only three ways you can run / compile a macro for every iteration of a data step:
dosubl()
run_macro
within an fcmp
callcall execute
- but note that any generated SAS code is executed AFTER the data step.The way it works is:
data test; set temp;
is sent to the stack, ready to be executed on the next step boundary
%macro cal_sum(iput);%mend;
macro is compiled (not executed)
REPORTING_DATE = &PROCDATE.;run;
is sent to the stack, and executed (as the run;
statement is a step boundary)
Upvotes: 1