proc sql;
select name into : table
from country.DETAIL
where ID = 34
and CD = "abc"
;
quit;
proc sql;
select name into : table
from country.DETAIL
where ID = &first_id.
and CD = "abc"
;
quit;
First query is running fine and second throwing error:
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, '.', /, <, <=, <>, =, >, >=, AND, EQ, EQT,
GE, GET, GROUP, GT, GTT, HAVING, LE, LET, LT, LTT, NE, NET, OR, ORDER, ^=, |, ||, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
can you please help why hard coding macro variable value is not giving any error but macro variable is giving error
Ideally it should not give error, could you please check the if the macro variable first_id is having the values
Please execute below code and check if it resolves to any value
%put &first_id;
Please run the code again with
options symbolgen;
and then post the whole log, using the {i} button.
Hi @kajal_30
You get this error if the macro variable first_id exists, but is assigned an empty value. It resolves to blank in the select, and the where-statement becomes where ID = and CD = "abc", which is illegal syntax.
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.