LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 1 Apr 2010 20:11:41 -0500
Reply-To:     Lou <lpogoda@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Lou <lpogoda@HOTMAIL.COM>
Organization: A noiseless patient Spider
Subject:      Re: The problem with sorting MONYY7. data
Comments: To: sas-l@uga.edu

"QiJun Fung" <coolcong@gmail.com> wrote in message news:2a884e16-5642-487a-aff9-d7ce5fc4866f@x3g2000yqd.googlegroups.com... > Hi all, > > I have a column "date" with type MONYY7. > eg. Jun2004 > Apr2001 > Apr2004 > . > .

No you don't. SAS has only two data types - character and numeric. You have either a character variable with values like those you cite, or you have a numeric variable associated with format MONYY7.

If it's a character variable, a sort will put the values in alphabetical order. If it's numeric with an associated format, the underlying values are the number of days since 01-Jan-1960, and a sort will put them in numeric order, which for dates means chronological order.

> > When I sort the data by "date", the order is by alphabetical order of > the initial not by its time order.Then the result is like: > Apr2001 > Apr2004 > Jun2004 > > How can I sort it by time order?

Chronologically, Apr2001 is before Apr2004, which in turn is before Jun2004. For the values in your example, chronological and alphabetical order are the same. And we can't tell if you're sorting character or numeric values from your example.

> Thanks very much. > > Cong


Back to: Top of message | Previous page | Main SAS-L page