Help using Base SAS procedures

Ordering the values in a cross tab output-data set is attached

Accepted Solution Solved
Reply
Super Contributor
Posts: 338
Accepted Solution

Ordering the values in a cross tab output-data set is attached

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_BandTotal
1 - 3030 - 6060 - 90CurrentNPNA
Days_Past_Due__oldest_Pmt_ 0001193122
0Frequency
1Frequency28000028
11Frequency200002
12Frequency100001
123Frequency000011
125Frequency000011
133Frequency000011
138Frequency000022
152Frequency000011
154Frequency000022
185Frequency000011
200Frequency000011
276Frequency000011
28Frequency100001
3Frequency100001
32Frequency080019
337Frequency000022
34Frequency010001
350Frequency000011
381Frequency000011
397Frequency000022
399Frequency000011
42Frequency010001
458Frequency000033
5Frequency100001
519Frequency000022
534Frequency000011
62Frequency002002
7Frequency100001
702Frequency000011
710Frequency000011
838Frequency000011
884Frequency000022
93Frequency000011
976Frequency000022
999Frequency00001616
3510211952218
TotalFrequency
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

Attachment

Accepted Solutions
Solution
‎11-06-2012 11:45 PM
Super User
Posts: 19,770

Re: Ordering the values in a cross tab output-data set is attached

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.

View solution in original post


All Replies
Solution
‎11-06-2012 11:45 PM
Super User
Posts: 19,770

Re: Ordering the values in a cross tab output-data set is attached

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.

Super Contributor
Posts: 338

Re: Ordering the values in a cross tab output-data set is attached

Thanks Reeza, your idea worked well. Now only I realized that the character and numeric varaibles are sorted differently.

Mirisage


🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 227 views
  • 0 likes
  • 2 in conversation