You were right! It seems that the Data-Step Compiler does not recognize: intnx("QUARTER", "¯o_date", &h, "E") as a constant. %macro macro_vs_datastep();
options fullstimer;
data input_dta;
length Date t 8;
do i = 1 to 100;
Date = intnx("MONTH", "01JAN1980"d, i, "E");
do t = 1 to 10000;
output;
end;
end;
run;
%let macro_date = 01JAN1980;
%let months_to_process = 100;
data data_step;
set input_dta;
%do h = 1 %to &months_to_process;
if Date = intnx("MONTH", "¯o_date"d, &h, "E") then output;
%end;
run;
data macro;
set input_dta;
%do h = 1 %to &months_to_process;
if Date = %sysfunc(intnx(MONTH, "¯o_date"d, &h, E)) then output;
%end;
run;
%mend;
%macro_vs_datastep(); Here's the log: NOTE: There were 1000000 observations read from the data set WORK.INPUT_DTA. NOTE: The data set WORK.DATA_STEP has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 18.73 seconds user cpu time 18.70 seconds system cpu time 0.03 seconds memory 1497.43k OS Memory 21272.00k Timestamp 04/29/2024 05:05:39 PM Step Count 59 Switch Count 9 NOTE: There were 1000000 observations read from the data set WORK.INPUT_DTA. NOTE: The data set WORK.MACRO has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 0.23 seconds user cpu time 0.21 seconds system cpu time 0.01 seconds memory 1195.31k OS Memory 21088.00k Timestamp 04/29/2024 05:05:40 PM Step Count 60 Switch Count 5 This could be specific to intnx(), other functions might be optimized to recognize this behavior, but good to know!
... View more