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

Hello,

I have a dataset of patients who reported alcohol consumption during the last  3 months,see below

What would be the most efficient  way of coding the patients into  three categories

1- No alcohol drink during the last 3 months

2-moderate  alcohol consumption ( those who reported drinking 25 glasses per month)

3-Excessive alcohol consumption ( those who reported drinking more than 25 glasses  per month 

 

Thank you.

 

 

data alcohol;
  input ID month1 month2 month3;
  datalines;

30300003
30301336
30302000
30303103535
30390202221
30391000
3039292022
30393679045
30501121132
3050041219
30502242
30503122


;

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21
mm = max(of month:);
if mm > 25 then cat = 3;
else if mm > 0 then cat = 2;
else cat = 1;
drop mm;
PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21
mm = max(of month:);
if mm > 25 then cat = 3;
else if mm > 0 then cat = 2;
else cat = 1;
drop mm;
PG
archibald
Obsidian | Level 7

This is great!! Thank you very much.

One more question, if  the month variable was such as alco_month_1, alco_month_2, and alco_month_last, how can this be  tranformed mm = max(of month:) ?

PGStats
Opal | Level 21
mm = max(of alco_month_:);
PG
archibald
Obsidian | Level 7

Thanks!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1532 views
  • 0 likes
  • 2 in conversation