Problem Note 68071: The ANYDTDTMw. informat does not read a datetime value with trailing characters correctly in the SAS® 9.4M4 (TS1M4) release and in later releases
Beginning with the SAS 9.4M4 maintenance release, using the ANYDTDTMw. informat to read a datetime value with character data at the end will return a missing value. Here are some examples of datetime values with character data at the end:
2020-11-12 02:22:56.26 UTC
2021-11-12 02:22:56.26 GMT
2021-6-10 12:20:30 America/Los_Angeles
The SAS® log does not indicate a problem with any INVALID DATA message, and the value will be missing. Datetime values with character data at the end like 2020-11-12 02:22:56.26 UTC are not supported by the ANYDT* informats. Beginning with the SAS® 9.4M8 (TS1M8) maintenance release, an INVALID DATA message will be produced in the SAS log to indicate that the value is not valid and the value will be missing.
A workaround is to read the datetime value as a character variable, use a function like the COMPRESS function to remove the character data, and then use the INPUT function with the ANYDTDTMw. informat to convert to a SAS datetime value.
Example code for this workaround is on the Full Code tab.
The output for the workaround code is on the Output tab.
Click the Hot Fix tab in this note to access the hot fix for this issue.
Note: An updated hot fix for this issue was provided on March 4, 2022. If you applied the hot fix from this note before March 4, click the Hot Fix tab again to access the updated hot fix.
After you apply the hot fix, an INVALID DATA message appears in the log for the SAS® 9.4M7 (TS1M7) release.
The hot fix applies to all three of the ANYDT* family of informats:
- ANYDTDTE
- ANYDTTME
- ANYDTDTM
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.4_M4 | | 9.4 TS1M4 | |
z/OS 64-bit | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft® Windows® for x64 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8 Enterprise 32-bit | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8 Enterprise x64 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8 Pro 32-bit | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8 Pro x64 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8.1 Enterprise x64 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8.1 Pro 32-bit | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 8.1 Pro x64 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows 10 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2008 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2008 R2 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2008 for x64 | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2012 Datacenter | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2012 R2 Datacenter | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2012 R2 Std | 9.4_M4 | | 9.4 TS1M4 | |
Microsoft Windows Server 2012 Std | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Enterprise 32 bit | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Enterprise x64 | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Home Premium 32 bit | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Home Premium x64 | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Professional 32 bit | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Professional x64 | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Ultimate 32 bit | 9.4_M4 | | 9.4 TS1M4 | |
Windows 7 Ultimate x64 | 9.4_M4 | | 9.4 TS1M4 | |
64-bit Enabled AIX | 9.4_M4 | | 9.4 TS1M4 | |
64-bit Enabled Solaris | 9.4_M4 | | 9.4 TS1M4 | |
HP-UX IPF | 9.4_M4 | | 9.4 TS1M4 | |
Linux for x64 | 9.4_M4 | | 9.4 TS1M4 | |
Solaris for x64 | 9.4_M4 | | 9.4 TS1M4 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
data one;
infile datalines dlm=',' dsd truncover;
input id checkin : $40. ;
temp=COMPRESS(checkin, '0123456789-:.', 'ks');
checkin2=input(temp,anydtdtm40.);
format checkin2 datetime25.2;
datalines;
1,2020-11-12 02:22:56.26 UTC
2,2021-11-12 02:22:56.26 GMT
3,2021-6-10 12:20:30 America/Los_Angeles
4,2021-7-10 12:20:30
;
run;
proc print;
run;
Obs id checkin temp checkin2
1 1 2020-11-12 02:22:56.26 UTC 2020-11-12 02:22:56.26 12NOV2020:02:22:56.26
2 2 2021-11-12 02:22:56.26 GMT 2021-11-12 02:22:56.26 12NOV2021:02:22:56.26
3 3 2021-6-10 12:20:30 America/Los_Angeles 2021-6-10 12:20:30 10JUN2021:12:20:30.00
4 4 2021-7-10 12:20:30 2021-7-10 12:20:30 10JUL2021:12:20:30.00
Type: | Problem Note |
Priority: | high |
Topic: | SAS Reference ==> Informats ==> Date and Time ==> ANYDTDTM
|
Date Modified: | 2022-06-13 09:54:53 |
Date Created: | 2021-06-22 14:30:08 |