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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.