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,

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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.

Mirisage
Obsidian | Level 7

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

Mirisage


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 813 views
  • 0 likes
  • 2 in conversation