Formatted order same as numeric:
For date values: yymmddn8. or yymmdd10.
For time values: tod11.2 (assumes your time values have hundredths of
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
dtformatted = put(dt/86400,yymmdd10.)||" "||put(dt,tod11.2);
Hope this helps.
----- Original Message -----
From: "Ya Huang" <ya.huang@AMYLIN.COM>
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.