Home Forums Main Forums SAS Forum A macro variable question: Call Symput() vs. Select Into

  • A macro variable question: Call Symput() vs. Select Into

     Justin updated 3 years, 4 months ago 2 Members · 2 Posts
  • Datura

    Member
    November 17, 2020 at 5:08 pm

    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?

  • Justin

    Administrator
    November 17, 2020 at 5:19 pm

    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 3 years, 4 months ago by  Justin.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now