hi there
i get the below error when trying to run my code
Error 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, THEN, ^, ^=, |
Syntax error, statement will be ignored
code:
proc sql;
select reference,
case when age >= 0 and age<= 10 then '0-10'
when age>=11 and age<=20 then '11-20'
end as AgeBucket
;quit;
Both queries look fine. Make sure you don't have spurious characters, like an extra comma or semi-colon. Missing spaces between the tokens so that your string literals look like other types of literals. 'xxx't is a TIME literal. Or just plain invalid characters, like TAB, CR, LF or non-breaking spaces , that might not show anything on the screen.
Your second one is more likely to cause errors because you have two quotes right next to each other. Put a space between them to make sure it looks like a string literal instead of just a doubled up embedded quote in the middle of some longer string literal.
Copy/paste (!!) the whole log, beginning with the PROC SQL statement and ending with the final NOTE about the SQL runtime into a box opened with this button:
Do not do anything else with the log text.
Copy the code and all the notes, messages or warnings along with the error messages. Paste all of that into a code box opened with the </>.
It is amazing how many times "code" shown does not actually turn out to be what was actually submitted. Copying the code with the messages for log confirms exactly what was submitted.
Typically a 22-322 error includes diagnostic characters indicating exactly where SAS determined the error occurred. So you only copied part of the error message and left out all the bits that were telling you where the actual error or was found.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.