I want to create a where statement where the variable is equal to 1,3 , or 4 but I am having trouble getting the output I want. I've tried a few methods but I'll just post the last one I tried. Basically I am trying to get the where statement to exclude 2 and only include 1, 3 and 4. Any suggestions? Thank you
Proc means data=data;
var chol;
class sex;
where (2>race>2);
run;
And "where" (put intended) did you learn the expression
where (2>race>2);
SAS will interpret this to mean the RACE is BOTH greater than 2 and less than 2. In other words, it insert an "and" not an "or". (Thus expressions like 1<race<3 function as actual subseting filters.
try:
where (race ^= 2);
And "where" (put intended) did you learn the expression
where (2>race>2);
SAS will interpret this to mean the RACE is BOTH greater than 2 and less than 2. In other words, it insert an "and" not an "or". (Thus expressions like 1<race<3 function as actual subseting filters.
try:
where (race ^= 2);
Thank you very much!
Alternate
Where race in (1 3 4);
if you know an explicit list of values that you want to keep. Some times the list to keep is shorter than a list to exclude so it is good to know multiple ways to filter values.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.