Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proc report and sorting months

Status
Not open for further replies.

nirmalraj

MIS
Apr 20, 2005
33
0
0
US
Hi,
I have month variable which I initially taken in as 1,2,3,4...Later while doing proc report, I use proc format
but while printing out the report, the values get sorted by alphabets and not by month order.Is there a way to fix this to make sure that Jan comes on top and Dec comes last.
Any help would be appreciated



Proc format;
Value mth 1='Jan'
2='Feb'
3='Mar'
4='Apr'
5='May'
6='Jun'
7='Jul'
8='Aug'
9='Sep'
10='Oct'
11='Nov'
12='Dec'
;

define month / 'Month' group format= mth.;


Regards,
Nirmal
 
By the way I am using proc report to output on excel, which I assume that excel automatically sorts by characters.

Any suggestions.

- Raj
 
Actually, this is a proc report issue. With some of the procedures you can use an "unformatted" option to sort by the data values rather than by the formatted values, unfortunately, Proc Report isn't one of them. I usually work around this by either adding the number to the start of the month so that the formatted values read "1 - Jan" etc. or, do the summarisation etc outside of proc report, then sort it to the correct order, then use proc report and use the "DISPLAY" option in the define statement rather than GROUP or ORDER. This last one looks better.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top