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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.