Hi Everyone;
I have a excel data file below:
ID type sys dia DM RF
1 b 131 86 1 0
1 a 136 89 1 0
1 c 120 80 1 0
1 d 138 70 1 0
2 b 150 90 0 0
2 a 160 89 0 0
2 c 140 90 0 0
2 d 146 91 0 0
3 b 120 78 0 1
3 a 136 81 0 1
3 c 131 80 0 1
3 d 110 70 0 1
I want to classify when DM and RF =0, if sys>=140 or dia>=90 then bp=1;
when DM=1, or RF=1, if sys>=130 or dia>=80 then bp=1;
else bp=0; I have tried different ways of
IF-THEN/ELSE Statements, but they did not work.
Thanks you so much for helping me.
Please try this.
data want;
set have;
if (sys=. or dia=.) then bp=.;
else if (sys>=140 or (sys>=130 and DM=1)
or (sys>=130 and RF=1) or (dia>=90 or (dia>=80 and DM=1)) or (dia>=80 and RF=1)) then bp=0;
else bp=1;
run;
Hi,
What final output are you expecting? Please share your syntax which you tried.
HI stat@sas,
Here are my syntax:
data BP;
set BP;
if (sys=.) or (dia=.) then bp=.;
else if (sys>=140) or ((sys>=130 and (DM=1)
or (sys>=130 and RF=1)) or (dia>=90) or ((dia>=80 and DM=1) or (dia>=80 and RF=1)) then bp=0;
else bp=1;
Thanks
Please try this.
data want;
set have;
if (sys=. or dia=.) then bp=.;
else if (sys>=140 or (sys>=130 and DM=1)
or (sys>=130 and RF=1) or (dia>=90 or (dia>=80 and DM=1)) or (dia>=80 and RF=1)) then bp=0;
else bp=1;
run;
It works pretty well. Thanks so much for your help.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.