BookmarkSubscribeRSS Feed
jeremy4
Quartz | Level 8

Hi,

 

Please can someone help to resolve the error in my Log? Thanks!

 

Code

data test;
   set RA.DATA_V_&START_yyyy.;
   if date = &month_end.;
run;

 

Log

data test;
27 set RA.DATA_V_&START_yyyy.;
28 if date = &month_end.;
NOTE: Line generated by the macro variable "MONTH_END".
28 30NOV2018
         _______
         22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,
LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.

29 run;

3 REPLIES 3
novinosrin
Tourmaline | Level 20
data test;
   set RA.DATA_V_&START_yyyy.;
   if date = "&month_end.";
run;

enclose in double quotes. This assumes your data is character.

 

If numeric, you need a date constant like

 

data test;
   set RA.DATA_V_&START_yyyy.;
   if date = "&month_end."d;
run;

 

 

Kurt_Bremser
Super User

I take it that "date" is a SAS date variable, so you need to make a SAS date literal out of your string:

data test;
   set RA.DATA_V_&START_yyyy.;
   if date = "&month_end."d;
run;

You would not need this if you had stored the raw value in your macro variable, see Maxim 28.

Tom
Super User Tom
Super User

You tried to run this statement:

if date = 30NOV2018 ;

That is not valid syntax.  SAS is expecting a valid expression on the right of the equal sign. What you gave it is not a valie varaible name nor a number nor a character string. 

Most likely you intended to run this statement.

if date = "30NOV2018"d ;

Which will compare DATE to a date literal.

 

So change your code to generate that.

if date = "&month_end"d ;

 

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
  • 377 views
  • 0 likes
  • 4 in conversation