BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mirisage
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
MikeZdeb
Rhodochrosite | Level 12

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

<=0

>  0 to <=80

> 80 to <=100

>100   

View solution in original post

3 REPLIES 3
Reeza
Super User

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.

MikeZdeb
Rhodochrosite | Level 12

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

<=0

>  0 to <=80

> 80 to <=100

>100   

Mirisage
Obsidian | Level 7

Hi MikeZdeb and Reeza,

Thank you very much for both of your responses.

Now I understand what has happened. Thanks Again.

Regards

Mirisage

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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