Help using Base SAS procedures

Why frequency bands jump here and there?

Accepted Solution Solved
Reply
Super Contributor
Posts: 338
Accepted Solution

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_RangeFrequencyPercentCumulativeCumulative
FrequencyPercent
<=0826785.23826785.23
>0 to <=80110852970.12119120775.35
>100686584.34125986579.69
>80 to <=10032108120.311580946100

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   

View solution in original post


All Replies
Super User
Posts: 19,769

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.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 171 views
  • 3 likes
  • 3 in conversation