BookmarkSubscribeRSS Feed
CatPaws
Calcite | Level 5

I'm trying to only keep certain observations in my data set, but when I do the IF statements, it is reporting no observations. Basically, I only want to keep observations that are considered confirmatory or presumptive, but I get the SAS error below. Why is it converting the column to numeric?

 

data All;
set xx;
If Highest_Evidence eq 'Confirmatory' or 'Presumptive';
run;

 

CatPaws_0-1644938425540.png

 

3 REPLIES 3
LinusH
Tourmaline | Level 20

Your variable seem to be numeriv, but you are using strings in you comparison - hence no match.

Data never sleeps
CatPaws
Calcite | Level 5

When I do them separately, it runs correctly, it's just when I put them together in the same statement I get the error.

PaigeMiller
Diamond | Level 26

You can't put them together like this:

 

If Highest_Evidence eq 'Confirmatory' or 'Presumptive';

This causes the error, as it is not the way to do such a comparison.

 

 

This is what you do want:

 

if Highest_Evidence eq 'Confirmatory' or Highest_Evidence eq 'Presumptive';

 

Alternatively, you could use:

if highest_evidence in ('Confirmatory','Presumptive');

 

Please, from now on, please present the LOG by copying the log as text (not as a screen capture), and then pasting it into the window that appears when you click on the </> icon. FROM NOW ON, DO NOT SKIP THIS STEP.

Insert Log Icon in SAS Communities.png

 

 

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 499 views
  • 2 likes
  • 3 in conversation