BookmarkSubscribeRSS Feed
Klakola
Calcite | Level 5

 

I have a program that has user input fields to create certain parameters throughout the code, in this case, a lookback period for a date/date range, and formatting is applied several times so that it works in various queries. I am getting an error at the calculation, however. Please help!


This is the error:

215 /**********************************************************************************************************************************************/

216 **macro to calculate lookback for staging based on incident start date;

217

218 data temp;

219 DTL = &date1. - &Days.;

_

22

200

WARNING: Apparent symbolic reference DAYS not resolved.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, arrayname, (, +, -, INPUT, NOT, PUT, ^, _NEW_, ~.

ERROR 200-322: The symbol is not recognized and will be ignored.

220 format DTL yymmdd10.;

221 run;

 

 

 

I've included below the relevant pieces of code.

"
/*SAS FORMATTED INCIDENT START DATE*/

%let date1 = '06Dec2019'd;

 

/**lookback x days**/

%let Days = 35; /*no lookback for staging, input "0"*/

/**********************************************************************************************************************************************/

**macro to calculate lookback for staging based on incident start date;

data temp;

DTL = &date1. - &Days.;

format DTL yymmdd10.;

run;

proc sql noprint;

select DTL into :DTLa

 

"

 

3 REPLIES 3
jmhorstman
Obsidian | Level 7

When I copied your code (excluding the final proc sql), it worked fine on SAS 9.4 on my PC.  I ended up with a data set called TEMP containing one observation with one variable called DTL having a numeric date value corresponding to Nov 1, 2019.  I did not receive the warning, because the macro variable Days resolved as expected.  I'm not sure why this isn't working for you.  Have you tried restarting your SAS session and just running this little bit of code?

Tom
Super User Tom
Super User

Are you just talking about the two macro variables that your code is defining and then using?

 

Show the line from the log with the error (before line number 215) where the macro variable DAYS was assigned a value.

 

Do you actually have a macro?  Is it possible you defined a local macro variable named DAYS in a macro that has now finished? Once a macro stops running its local macro scope disappears.

PaigeMiller
Diamond | Level 26

Despite the code you showed, it seems as if &DAYS has not been defined. So I conclude you didn't run the code you showed.

 

So, place this command at the start of your code

options mprint symbolgen mlogic;

and run it again.

 

Then copy the log (the entire log, not just the error messages) as text and paste it into the window that appears when you click on the {i} icon. DO NOT SKIP THIS STEP. This helps keep the formatting of the log readable. Please help us out, and help us help you, by following these instructions.

 

 

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 1018 views
  • 0 likes
  • 4 in conversation