I have the following macro which I will use inside a data step:
%global var3;
%macro add(var1,var2);
%let var3 = %eval(&var1+&var2);
%mend;
I don't understand the results of the following data step:
%let var3 = 2;
data test;
put "The value of var3 is &var3";
x = 3 - &var3;
%add(7,3);
%put &=var3;
run;
From what I understand, macro statements are executed before compilation of a data step. So in this case macro %add is executed first and then %put statement. However, the value of x is 1, not -7. And also put statement prints The value of var3 is 2, instead of 10. I am confused.