Calcite | Level 5

## How to categorize data when raw data is not 1,2,3 etc.

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?

This is the code I have used to categorize the raw data as 1,2,3Result! Frequency missing

1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

## Re: How to categorize data when raw data is not 1,2,3 etc.

``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 ...``
--
Paige Miller
5 REPLIES 5
Super User

## Re: How to categorize data when raw data is not 1,2,3 etc.

101 - 199 is 99 so you're checking if your value is 99.

I think you want:

if alcday5 in (101:199) then alcohol = 3;

OR

if alcday5 >= 101 and alcday5 <=199 then alcohol = 3;

Please post code as text not images in the future.
Calcite | Level 5

## Re: How to categorize data when raw data is not 1,2,3 etc.

I figured it out!

if 101<=alcday5<=199 then alcohol = 3;
if 201<=alcday5<=299 then alcohol = 2;
if alcday5 = 888 then alcohol = 1;

Diamond | Level 26

## Re: How to categorize data when raw data is not 1,2,3 etc.

``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 ...``
--
Paige Miller
Calcite | Level 5

## Re: How to categorize data when raw data is not 1,2,3 etc.

Yep, exactly! Thank you
Super User

## Re: How to categorize data when raw data is not 1,2,3 etc.

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.

Discussion stats
• 5 replies
• 594 views
• 0 likes
• 4 in conversation