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 !
R
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;
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;
The variable name is missing and also your variable is Number not char. Use this:
if ImplantNYHA in(0,99) then ImplantNYHA=.;
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);
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.