BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Rodrigue
Obsidian | Level 7

Dear all,

 

I have a row (ImplantNYHA) with different values (0,1,2,3,4,99).

I would like to change the 0 and 99 values by "." and keep the 1, 2 , 3 and 4 as they are

I tried 

data try; set ICDCRTdatabase;

if ImplantNYHA = 99 then ".";

if ImplantNYHA = 0 then ".";

then ImplantNYHA = ImplantNYHA;

run;

 

I attached the output.

 

Thank you !

 

RCapture d’écran 2021-07-14 à 22.49.26.png

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
Kurt_Bremser
Super User

You need to make a valid assignment, and you can simplify the condition:

data try;
set ICDCRTdatabase;
if ImplantNYHA in (0,99) then ImplantNYHA = .;
run;
Rodrigue
Obsidian | Level 7
Thank you !
Rydhm
Obsidian | Level 7

The variable name is missing and also your variable is Number not char. Use this:

if ImplantNYHA in(0,99) then ImplantNYHA=.;

Reeza
Super User

Is your variable numeric or character?

If it's character you need to use the quotes around the values, if it's numeric you do not. You use it on one part of the code and then not the other so not sure. SAS didn't error/warn on your comparison so I'm going to assume it's numeric.

FYI you can also use the CALL MISSING() routine where it doesn't matter what the types are.

*for character values;
if imp1nyha in ('0', '99') then call missing(imp1nyha);
*for numeric values;
if imp1nyha in (0, 99) then call missing(imp1nyha);
tarheel13
Rhodochrosite | Level 12
It looks like it’s a numeric variable so you would not need the “”.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1107 views
  • 4 likes
  • 5 in conversation