Help using Base SAS procedures

Multiple If then

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

Multiple If then


Hello-

I am trying to determine if a patient can be classified as 'GLAU'  There are a total of five tests a patient may be given and any 'y' would classify the patient as GLAU.   The data looks like below.   I've been writing separate if then statements for each test and was wondering if there is an easier way to write code.  Any help would be appreciated. 

patientinner_eye_pressureoptic_nervefield_visioniris_corneacornea
15385y y
15953 yy
14385y y
15996 y
15335yy
15004 y
15843 y
15385 y

Accepted Solutions
Solution
‎06-25-2013 06:12 PM
Super User
Posts: 19,873

Re: Multiple If then

I was too lazy to type out the variables but the whichc function will work.

You could also nest it into an ifc function if you wanted a oneliner piece of code, but more ppl understand this, I find.

if whichc('y', var1, var2, var3, var4, var5)>0 then classify="GLAU";

else classify = "Other"

View solution in original post


All Replies
Solution
‎06-25-2013 06:12 PM
Super User
Posts: 19,873

Re: Multiple If then

I was too lazy to type out the variables but the whichc function will work.

You could also nest it into an ifc function if you wanted a oneliner piece of code, but more ppl understand this, I find.

if whichc('y', var1, var2, var3, var4, var5)>0 then classify="GLAU";

else classify = "Other"

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 139 views
  • 0 likes
  • 2 in conversation