BookmarkSubscribeRSS Feed

It would be handy if SAS accepted date literals in ISO format:

'2018-04-05'd

and datetime literals:

'2018-04-04T08:34:25.678'dt  (the "T" may be replaced by a blank)

in addition to the default DATE9. format.

7 Comments
RW9
Diamond | Level 26
Diamond | Level 26

It would indeed.  I don't believe any of the literals have been updated in years.

ballardw
Super User

I think that instead of

'2018-04-05'd

that a reference like

'2018-04-05'id  or '2018-04-04T08:34:25.678'idt  

to indicate that the user does indeed intend to use an ISO date literal might be a slightly better idea. Then the compiler actually has something to grab and use the correct algorithm.

 

Overloading a literal indicator sounds like a coding nightmare. And since we see enough examples of people attempting to misuse the current date, datetime and time literals I'm not sure that I want  spend more time explaining why date literals in all the other forms attempted aren't valid.

Kurt_Bremser
Super User

Good and valid idea, @ballardw!

DaveShea
Lapis Lazuli | Level 10

I really like the general idea of opening up the date and datetime literals to, at least, using the ISO formats. I wonder if it would be better to allow the literals to accept any of the values currently accepted by the ANYDTDTE or ANYDTDTM informats ?

 

I'd be happy to accept BallardW's idea of an expanded family of literals such as id or idt or even a broad-minded ad or adt to allow for a nice bit of backwards compatability.

 

Cheers,

 

Downunder Dave

Wellington

Kurt_Bremser
Super User

I see that it is already implemented:

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lrcon&docsetTarget=p0cq7f...

 

With and without timezone

With an without the "T"

Kurt_Bremser
Super User

Alas, only for datetime literals, not for dates.

barefootguru
Fluorite | Level 6

@Kurt_Bremser the ISO format is only documented with the timezone info, so unwise to rely on it for plain ISO timestamps.