I was surprised to find out that the IN operator is not supported variable names.
If things change, just let me know
data demo;
x=1;
run;
data demo1;
set demo;
if x in (1,2) then flag=1;
run;
data demo2;
set demo;
y=1;
if x = y or x =2 then flag=1;
run;
data demo3;
set demo;
y=1;
if x in (y,2) then flag=1;
run;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,
a missing value, iterator, (.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
As Freelancer showed you ,you should use array operator:
data demo;
x=1;
run;
data demo3;
set demo;
array _x y z ;
y=1;z=2;
if x in _x then flag=1;
run;
P.S. variable z and _x must be not exist in dataset demo.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.