## Why frequency bands jump here and there?

Solved
Super Contributor
Posts: 338

# Why frequency bands jump here and there?

Hi Forum,

I have taken the freq distribution of a variable named “income” employing this code (for confidentiality I cannot attach the data set).

data want;

length Income_Range \$15;

set have;

if Income_ = . then Income_Range='Missing';

else if Income_   <=0   then Income_Range = '<=0';

else if Income_   <=80 then  Income_Range ='>0 to <=80';

else if Income_   <=100 then  Income_Range ='>80 to <=100';

else Income_Range = '>100';

run;

proc freq data=want;

tables Income_Range;

run;

Question:

However much I tried, the output table comes with “Income_Range” bands being jumped (meaning there are not in sequence).

Could anyone please let me know any reason for this?

 Income_Range Frequency Percent Cumulative Cumulative Frequency Percent <=0 82678 5.23 82678 5.23 >0 to <=80 1108529 70.12 1191207 75.35 >100 68658 4.34 1259865 79.69 >80 to <=100 321081 20.31 1580946 100

The sequence of Income_Range column of above table should have been like below.

 Income_Range <=0 >0 to <=80 >80 to <=100 >100

Thank you for any help.

Mirisage

Accepted Solutions
Solution
‎07-12-2012 01:48 PM
Valued Guide
Posts: 765

## Re: Why frequency bands jump here and there?

hi ... use a format (as suggested) or add some spaces ...

<=0

>  0 to <=80

> 80 to <=100

>100

All Replies
Super User
Posts: 23,724

## Re: Why frequency bands jump here and there?

That's because your variables are now characters and SAS is sorting it according to the character values, so 'alphabetic' order, which makes sense.

Using a format instead of recoding should solve that, if its an option.

Solution
‎07-12-2012 01:48 PM
Valued Guide
Posts: 765

## Re: Why frequency bands jump here and there?

hi ... use a format (as suggested) or add some spaces ...

<=0

>  0 to <=80

> 80 to <=100

>100

Super Contributor
Posts: 338

## Re: Why frequency bands jump here and there?

Hi MikeZdeb and Reeza,

Thank you very much for both of your responses.

Now I understand what has happened. Thanks Again.

Regards

Mirisage

🔒 This topic is solved and locked.