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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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