Hi, from raw data I have always found 1,2,3, likewise but in this particular reserch question in raw data 101-199, 201-299, 888! If I use the below code I get only raw data 888 results because this code only worked not the 101-199 or 201-299. How do I fix that?
if alcday5 = 101-199 then ...
one hundred one minus one hundred ninety nine is negative 98 (that's how the minus sign is interpreted in this code in SAS)
So this code is not doing what you want it to do, since alcday5 is never equal to –98
You probably want this:
if 101<=alcday5<=199 then ...
I figured it out!
if 101<=alcday5<=199 then alcohol = 3;
if 201<=alcday5<=299 then alcohol = 2;
if alcday5 = 888 then alcohol = 1;
if alcday5 = 101-199 then ...
one hundred one minus one hundred ninety nine is negative 98 (that's how the minus sign is interpreted in this code in SAS)
So this code is not doing what you want it to do, since alcday5 is never equal to –98
You probably want this:
if 101<=alcday5<=199 then ...
And for the $64,000 question, WHAT interpretation is Alcohol=2? and Alcohol=3?
The question reads like an assignment so I won't argue with the coding but the use is a completely different matter.
If it is supposed to be a "severity" measure then you may want to consider which is more "severe" 1 drink per week (101) or 99 drinks per month (299)?
If the source is as I think, then wait until you try to reconcile the "drinks per occasion" with the other related variables.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.