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!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 866 views
  • 0 likes
  • 2 in conversation