BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chirumalla
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

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.

Data never sleeps

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

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.

Data never sleeps
chirumalla
Calcite | Level 5

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;

LinusH
Tourmaline | Level 20

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.

Data never sleeps
Astounding
PROC Star

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.

sas-innovate-white.png

🚨 Early Bird Rate Extended!

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.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 36568 views
  • 3 likes
  • 3 in conversation