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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

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;

View solution in original post

4 REPLIES 4
stat_sas
Ammonite | Level 13

Hi,

What final output are you expecting? Please share your syntax which you tried.

xinjian
Calcite | Level 5

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


stat_sas
Ammonite | Level 13

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;

xinjian
Calcite | Level 5

It works pretty well. Thanks so much for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 2251 views
  • 0 likes
  • 2 in conversation