I have a dataset with
X: Character Variable
Y: Numeric Variable
I want to obtain the dataset with
X = a or b AND Y= 1
how do I write the code?
I understand that if I use "where" both variables must be of the same type (both character or both numeric).
Thank you
WHERE just want a valid boolean expression.
where (X = 'a' or X='b') AND (Y= 1) ;
WHERE just want a valid boolean expression.
where (X = 'a' or X='b') AND (Y= 1) ;
Alternative code,
Where X in ('a','b') and Y=1;
Thanks,
jag
Alternately u can use:
Data want;
set have;
if x in ("a","b") then output;
where y=1;
run;
Hi ..
You can use any condition, which is provided by tom, jegadish and karthik. and also you can use proc sql to print the same result. where if you use the proc sql, it should take less time to execute the code rather than using data step. Thanks, yaswanth
proc sql;
select * from sasuser.admit
where actlevel in ('HIGH','LOW')
and fee gt 100;
quit;
Thanks, yaswanth
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.