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