Hello,
I’m trying to call a macro within a data step and only seems to be evaluating on the second run of the my program!
For example, if i run the following code below, N, T1, T2 and T3 will be null even though the log shows the macro has run and set each global variable.
Only when the program is run a second time (within the SAS session), dataset TEST is written too.
I’m desperate to find a solution to this if possible? Why does it only compute on the second run of the SAS program.
Thank you in advance. Lakes74.
Data look_up;
input id D1 $ D2 $ D3 $;
datalines;
1 A B C
2 D E F
3 G H I
4 J K L
5 M N O
6 P Q R
7 S T U
8 V W X
9 Y Z A
;
run;
%global var1;
%global var2;
%global var3;
%macro temp(number);
proc sql noprint;
select D1,D2,D3 into :var1, :var2, :var3
from look_up
where id = &number;
quit;
%mend;
%let id = 2;
data test;
call execute ('%temp('||put(&id,3.)||')');
N = "&id";
T1 = "&var1";
T2 = "&var2";
T3 = "&var3";
run;
%put &var1;
%put &var2;
%put &var3;
... View more