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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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