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;
30300 | 0 | 0 | 3 |
30301 | 3 | 3 | 6 |
30302 | 0 | 0 | 0 |
30303 | 10 | 35 | 35 |
30390 | 20 | 22 | 21 |
30391 | 0 | 0 | 0 |
30392 | 9 | 20 | 22 |
30393 | 67 | 90 | 45 |
30501 | 12 | 11 | 32 |
30500 | 4 | 12 | 19 |
30502 | 2 | 4 | 2 |
30503 | 1 | 2 | 2 |
;
mm = max(of month:);
if mm > 25 then cat = 3;
else if mm > 0 then cat = 2;
else cat = 1;
drop mm;
mm = max(of month:);
if mm > 25 then cat = 3;
else if mm > 0 then cat = 2;
else cat = 1;
drop mm;
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:) ?
mm = max(of alco_month_:);
Thanks!!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.