Date: Thu, 30 Jul 2009 12:20:59 -0500
Reply-To: Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Subject: Re: consistency of sorting a date or time var in num and char
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original
Formatted order same as numeric:
For date values: yymmddn8. or yymmdd10.
For time values: tod11.2 (assumes your time values have hundredths of
seconds)
As far as I know, there is no built-in format for datetime values that would
produce the same sort order for formatted values as for the underlying
numeric values. You would either have to roll your own or perhaps use an
expression like:
dtformatted = put(dt/86400,yymmdd10.)||" "||put(dt,tod11.2);
Hope this helps.
s/KAM
----- Original Message -----
From: "Ya Huang" <ya.huang@AMYLIN.COM>
To: <SAS-L@LISTSERV.UGA.EDU>
Sent: Thursday, July 30, 2009 11:33
Subject: consistency of sorting a date or time var in num and char
> Hi there,
>
> Obviously sorting a date var as numeric is different from a date9.
> formatted character, since '03JAN2009' is ordered after '03APR2009'.
> But '03JAN2009'DT should have the same order as '01032009'. For time
> var, a time5. formatted string will not have the same order as the
> underline numeric var, since time5. is not zero padded.
>
> I wonder what kind of formatted date, time or datetime var have
> the same order as the underline numeric var.
>
> Thanks
>
> Ya
>
|