Hi All,
I'm using below code to get last month data set when I try to run first time it's giving error/warning and if I ran same code again it's running successfully and giving vales how to trouble shoot this first run issue. pls advise me.
%LET JOBNAME=acardact_;
data _NULL_;
date1=intnx('MONTH',today(),-1,'SAMEDAY');
CALL SYMPUT("LOAD", TRIM(LEFT(PUT(DATE1, YYMMN6.))));
LOAD_T= "&JOBNAME"||"&LOAD";
CALL SYMPUT ("LOAD_DATE", LOAD_T);
%PUT &LOAD_DATE;
run;
Expecting value----- acardact_201401
LOG
124 %LET JOBNAME=acardact_;
125 data _NULL_;
126 date1=intnx('MONTH',today(),-1,'SAMEDAY');
127 CALL SYMPUT("LOAD", TRIM(LEFT(PUT(DATE1, YYMMN6.))));
128 LOAD_T= "&JOBNAME"||"&LOAD";
WARNING: Apparent symbolic reference LOAD not resolved.
129 CALL SYMPUT ("LOAD_DATE", LOAD_T);
130 %PUT &LOAD_DATE;
WARNING: Apparent symbolic reference LOAD_DATE not resolved.
You can't put a macro variable that doesn't even exist... + (&x).
A is a data step variable in your example, not a macro variable.
Since macro variables are evaluated at compile time, date1 haven't been set at that time.
Just use data step variables, and then do call symput at the end.
Or just use macro code, not necessary to use a data step for this kind of logic.
Hi
I tried this still I'm facing same issue pls help me how to resolve if possible give me code.
data _null_;
x = intnx('MONTH',today(),-1,'SAMEDAY');
%put &x;
run;
see below log
================================================
15 data _null_;
16 x = intnx('MONTH',today(),-1,'SAMEDAY');
17 %put &x;
WARNING: Apparent symbolic reference X not resolved.
&x
18 run;
You can't put a macro variable that doesn't even exist... + (&x).
A is a data step variable in your example, not a macro variable.
Move the RUN; statement to before the %PUT statement. You have to force the DATA step to complete in order to create your macro variable.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.