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

hello,

I'm trying to find a solution how to apply multple conditions, or another code that can help me with this condition.

My outcome is "MetSind", and I have 5 condtions. At least there should be accomplished three of them to get MetSind=yes

1. waist>88

2. tg>=150 or hyplip_treat=yes

3. hdl_c<50

4. msbp>=130 or mdbp>=85 or hta_treat=yes

5. glu>=100 or dm_dx=yes

 

I was trying to use this code: if ((waist>88) or (tg>=150 or hyplip_treat=yes) or (hdl_c<50) or (msbp>=130 or mdbp>=85 or hta_treat=yes) and (glu>=100 or dm_dx=yes)) then MetS=1 ; else MetS=0. But, clearly it doesn't work.

I am beginner sas user so I would like some expert's help.

 

Thanks for replying.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Make use of the fact that boolean values in SAS are represented as 0 and 1:

if
  (waist > 88) +
  (tg >= 150 or b6_1_3 = 2) +
  (hdl_c < 50) +
  (msbp >= 130 or mdbp >= 85 or b6_1_2 = 2) +
  (glu_0 >= 100 or dm_dx = 2)
>= 3
then MetS = 1;
else MetS = 0;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Make use of the fact that boolean values in SAS are represented as 0 and 1:

if
  (waist > 88) +
  (tg >= 150 or b6_1_3 = 2) +
  (hdl_c < 50) +
  (msbp >= 130 or mdbp >= 85 or b6_1_2 = 2) +
  (glu_0 >= 100 or dm_dx = 2)
>= 3
then MetS = 1;
else MetS = 0;
Lop
Fluorite | Level 6 Lop
Fluorite | Level 6

Thank you so much for your valious feedback. It worked perfect.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 461 views
  • 3 likes
  • 2 in conversation