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
"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