07-12-2012 01:40 PM
I have taken the freq distribution of a variable named “income” employing this code (for confidentiality I cannot attach the data set).
length Income_Range $15;
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';
proc freq data=want;
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?
|>0 to <=80||1108529||70.12||1191207||75.35|
|>80 to <=100||321081||20.31||1580946||100|
The sequence of Income_Range column of above table should have been like below.
|>0 to <=80|
|>80 to <=100|
Thank you for any help.
07-12-2012 01:45 PM
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.
07-12-2012 02:35 PM
Hi MikeZdeb and Reeza,
Thank you very much for both of your responses.
Now I understand what has happened. Thanks Again.
Need further help from the community? Please ask a new question.