BookmarkSubscribeRSS Feed
kgrover
Calcite | Level 5

I have used the following code to define use disorder if 2 or more questions are answered as yes. This statement works for this purpose. 

 

data mergeTOB2; set mergeTOB1;
array num{*} CIINTERF--CIPROBLM;
TOBDORD = sum (of num(*)) ge 2;
run; 

 

How can i modify this statement to define mild and moderate disorder, where sum of ge 2 but lt 3 is mild and ge 4 is moderate? 

 

 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

So it can be only mild and moderate, or?

kgrover
Calcite | Level 5

less than 2 = no disorder; 2 to 3 = mild disorder; 4 or more = moderate/severe

Astounding
PROC Star

Maybe in SQL you could assign three different values with a single CASE statement.  But in a DATA step you will need two variables:

 

data mergeTOB2;

set merge TOB;

array num {*} CIINTERF--CIPROBLM;

TOBDORD = sum(of num{*});

if tobdord >= 4 then result = "moderate/severe";

else if tobord = 3 then result = "mild";

else result = "no disorder";

run;

 

You could consider dropping TOBORD once RESULT is created.  Alternatively, you could skip creating RESULT entirely and just let TOBORD be your new variable.  When it comes time to print, you could add a format that translates numeric values into descriptive strings, such as:

 

proc format;

value result low-2 = "no disorder"

  3 = "mild"

  4-high = "moderate/severe";

run;

 

Another variation:  it's not clear if you want to get rid of the observations with counts of 2 or less.  The last ELSE statement could become (if needed):

 

else delete;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 1000 views
  • 0 likes
  • 3 in conversation