mercredi 28 octobre 2015

If-Then-Else Loop in SAS keeps producing one wrong output

I'm trying to create a loop that will tell me if a patient is hypertensive or not by the conditions of if the patient is female and the SBP is greater than 138 and the DBP is greater than 88 and for males if their SBP is greater tha 140 and their DBP is greater than 90. For some reason my loop keeps leaving out the M 142 82 patient which should be Yes but it keeps listing it as No.

title "Hypertensive Patients";
proc report data=learn.bloodpressure;
column Gender SBP DBP Hypertensive;
define Gender / Group width=6;
define SBP / display width=5;
define DBP / display width=5;
define Hypertensive / computed "Hypertensive?" width=13;
compute Hypertensive / character length=3;

if Gender = 'F' and SBP gt 138 or DBP gt 88
then Hypertensive = 'Yes';
else Hypertensive='No';
if Gender = 'M' and
SBP gt 140 or DBP gt 90
then Hypertensive = 'Yes';
else Hypertensive = 'No';

endcomp;
run;
quit;

Hypertensive Patients Gender SBP DBP Hypertensive? F 110 62 No 120 70 No 138 88 No 132 76 No M 144 90 Yes 130 80 No 142 82 No 150 96 Yes

Any ideas on what the problem is?

Aucun commentaire:

Enregistrer un commentaire