Hi Forum,
Apologize for multiple postings but this posting attaches my data set which makes my question clearer.
When I ran the follwoing code on the attached dataset, it generated the follwing table where the values of the variable named
Days_Past_Due__oldest_Pmt_ is not in any order.
proc freq data=a.have_1 ;
tables Days_Past_Due__oldest_Pmt_ * arrears_band/ nocol norow nopct;
run;
Question: Is there any option in proc freq to arrange the values of
variable named Days_Past_Due__oldest_Pmt_ in ascending order?
I have the excellent code posted by Ksharp for a similar question like this (reproduced at the very bottom) but in that example the "colum variable" had a limited number of vlaues.
But this specific problem has too many values for the "column variable" which precludes the replication of that code for this example .
Table of Days_Past_Due__oldest_Pmt_ by Arrears_Band | |||||||
Arrears_Band | Total | ||||||
1 - 30 | 30 - 60 | 60 - 90 | Current | NPNA | |||
Days_Past_Due__oldest_Pmt_ | 0 | 0 | 0 | 119 | 3 | 122 | |
0 | Frequency | ||||||
1 | Frequency | 28 | 0 | 0 | 0 | 0 | 28 |
11 | Frequency | 2 | 0 | 0 | 0 | 0 | 2 |
12 | Frequency | 1 | 0 | 0 | 0 | 0 | 1 |
123 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
125 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
133 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
138 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
152 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
154 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
185 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
200 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
276 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
28 | Frequency | 1 | 0 | 0 | 0 | 0 | 1 |
3 | Frequency | 1 | 0 | 0 | 0 | 0 | 1 |
32 | Frequency | 0 | 8 | 0 | 0 | 1 | 9 |
337 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
34 | Frequency | 0 | 1 | 0 | 0 | 0 | 1 |
350 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
381 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
397 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
399 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
42 | Frequency | 0 | 1 | 0 | 0 | 0 | 1 |
458 | Frequency | 0 | 0 | 0 | 0 | 3 | 3 |
5 | Frequency | 1 | 0 | 0 | 0 | 0 | 1 |
519 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
534 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
62 | Frequency | 0 | 0 | 2 | 0 | 0 | 2 |
7 | Frequency | 1 | 0 | 0 | 0 | 0 | 1 |
702 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
710 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
838 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
884 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
93 | Frequency | 0 | 0 | 0 | 0 | 1 | 1 |
976 | Frequency | 0 | 0 | 0 | 0 | 2 | 2 |
999 | Frequency | 0 | 0 | 0 | 0 | 16 | 16 |
35 | 10 | 2 | 119 | 52 | 218 | ||
Total | Frequency | ||||||
Frequency Missing = 102 |
Previous code for a similar problerm but not exactly the same type (Ksharp is acknowledged).
data x;
input a & $10. b & $10.;
cards;
. .
Current Current
1 - 30 Delinquent
30 - 60 Default
60 - 90 NPNA
90+ Current
NPNA Current
;
run;
proc format ;
value $ fmt
' '=' Missing'
'Current' = ' Current'
'1 - 30' = ' 1 - 30'
'30 - 60' = ' 30 - 60'
'60 - 90' =' 60 - 90'
'90+' =' 90+'
'Default'= 'Default'
'Delinquent'= ' Delinquent'
'NPNA' = 'NPNA'
;
run;
proc freq order=formatted;
tables b*a/missing ;
format a b $fmt.;
run;
Thanks
M
Days_Past_Due__oldest_Pmt_is a character variable, change it to a number and it will sort properly.
It is sorted alphabetically by the way, not in any order.
Days_Past_Due__oldest_Pmt_is a character variable, change it to a number and it will sort properly.
It is sorted alphabetically by the way, not in any order.
Thanks Reeza, your idea worked well. Now only I realized that the character and numeric varaibles are sorted differently.
Mirisage
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.
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.