DATA Step, Macro, Functions and more

re: error message

Accepted Solution Solved
Reply
Regular Contributor
Posts: 229
Accepted Solution

re: error message

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.

 


Accepted Solutions
Solution
‎05-30-2016 08:04 PM
Super User
Posts: 3,252

Re: re: error message

[ Edited ]

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;

 

View solution in original post


All Replies
Regular Contributor
Posts: 212

Re: re: error message

[ Edited ]

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

Solution
‎05-30-2016 08:04 PM
Super User
Posts: 3,252

Re: re: error message

[ Edited ]

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;

 

Regular Contributor
Posts: 229

Re: re: error message

Hi...thanks....the double quotation marks rather than the single quotation marks resolved the problem and worked perfectly.
SAS Super FREQ
Posts: 8,865

Re: re: error message

Hi:
Without seeing more of your code, it looks to me like you need to specify date constants in your do loop:
do date="&FROMYEAR7"d to "&TOYEAR7"d;

Please review this example: http://support.sas.com/kb/24/573.html

When you are using Macro variables as the start and end variables, you need to enclose your macro variable values in double quotes (instead of single quotes), but the trailing D to indicate a date value is required. Otherwise, you get an error because this:

do date=01JAN1900 to 31DEC2100;

is not valid in code, but this would be:

data testit;
do date="01JAN1900"d to "31DEC2100"d;
put 'internal= ' date '~~~' 'formatted= ' date date9.;
end;
run;

cynthia
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1251 views
  • 4 likes
  • 4 in conversation