An Idea Exchange for SAS software and services

Comments
by Respected Advisor
3 weeks ago - last edited 3 weeks ago

I think the problem with doing this is that some numeric values cannot be uniquely determined to be a date or a datetime.

 

A value of 1846147693 can't be a date, it has to be a datetime. But a value of 21367 could indicate July 2, 2018 or it could indicate a datetime of around 6am on 01JAN60.

by Super User
3 weeks ago

Note that SAS has started to address this, by creating formats that print datetimes in a date format.  See these examples:  DTDATEw., DTMONYYw., DTWKDATXw., DTYEARw., DTYYQCw.

 

You still need to know which of your variables are datetimes, and apply the formats in the appropriate cases.

by Regular Contributor
3 weeks ago

@ if the number is formatted as a datetime, date functions should work on it.

by Respected Advisor
3 weeks ago

@tomrvincent Is this an additional requirement for this idea? That a format exists for the variable? I am not aware of any SAS calculation functions where the behavior of the function depends on the format of the variable used in the function.

 

But this doesn't really address my point. SAS date values, and SAS datetime values are just numbers. What if someone writes code and doesn't apply a format, because the usage in the program doesn't require a format? Then the decision of whether the number is a date or a datetime is ambiguous.

by Regular Contributor
3 weeks ago

If it's 'just a number', it really isn't a date or a datetime.  I think *all* date functions (month, day, etc.) should *only* work on dates/datetimes.  That's the only times they are relevant.

Idea Statuses
Top Liked Authors