Hi...I am trying to do a loop from one date to another but I am getting the following error message 22-322...any suggestions how to correct this...Thanks.
269 DATA K;
270 do date=&FROMYEAR7 to &TOYEAR7;
NOTE: Line generated by the macro variable "FROMYEAR7".
270 01JAN1900
_______
22
NOTE: Line generated by the macro variable "TOYEAR7".
270 31DEC2100
_______
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -,
/, <, <=, <>, =, >, ><, >=, AND, BY, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE,
NG, NL, NOTIN, OR, ^=, |, ||, ~=.
271 if date= &FROMYEAR7 then do;
NOTE: Line generated by the macro variable "FROMYEAR7".
271 01JAN1900
_______
388
76
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
Since your macro variables resolve to SAS dates you need to reference them as date strings like so (assuming the date variable is in fact a SAS date):
do date="&FROMYEAR7"d to "&TOYEAR7"d;
Hi mate,
It is possible that you missed out some operator during your do loop. Checkout the syntax and paste the code here if possible
tks
Since your macro variables resolve to SAS dates you need to reference them as date strings like so (assuming the date variable is in fact a SAS date):
do date="&FROMYEAR7"d to "&TOYEAR7"d;
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.
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.