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;
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;
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.
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 ;
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.
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.
Ready to level-up your skills? Choose your own adventure.