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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1546 views
  • 0 likes
  • 2 in conversation