Home › Forums › Main Forums › SAS Forum › A macro variable question: Call Symput() vs. Select Into
-
A macro variable question: Call Symput() vs. Select Into
-
In SAS, if we run below code to create a macro variable:
data AAA;
X='25DEC2020'd;
format X date9.;
call symput("MV_1", X);
run;
%put MV_1=*&MV_1*;
proc sql;
select X into: MV_2
from AAA;
quit;
%put MV_2=*&MV_2*;We will find that the values of the two macro variables are different. Below shows SAS log:
MV_1=* 22274*
MV_2=*25DEC2020*Who can tell me why?
-
It is true. This is one of the distinct differences between Call Symput() and Select Into in creating macro variables. Thus when we need to reference the macro variables, the reference methods are totally different too. Please see the syntax below.
data CCC;
set BBB;
where Birth_Date< &MV_1 ;
where Birth_Date< "&MV_2"n ;
run;Please note: your code will fail to work if you do NOT reference them correctly. Be careful, details are critically important in programming.
- This reply was modified 4 years, 1 month ago by Justin.
Log in to reply.