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 ;

 

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
  • 3 replies
  • 649 views
  • 0 likes
  • 4 in conversation