1
votes

SAS question. I am creating a variable where if different logic rules are met it takes on one of two values. Let's say the binary variable I'm creating is RiskScore and there are three conditions A, B, and C that determine which risk score an observation takes on. How would I do this in SAS?

Condition A: Age > 70 Condition B: Cholesterol > 200 Condition C: Has diabetes

If at least two of conditions A, B, or C are TRUE then RiskScore=High; Else RiskScore=Low;

Thanks for your help!

1

1 Answers

2
votes

In SAS true/false are 1/0, so if you add up your conditions and it's greater than or equal to 2 then you're good to go.

 if sum(age>70, chol>200, diabetes=1)>=2 then do;