I'm dealing with an API that returns timestamps as strings such as "Wed Apr 30 13:44:54 GMT 2025"
ANYDTDTM. informat does not properly parse the timestamp from the string.
The construct looks like it is from Java via
DateTimeFormatter.ofPattern("E M d k:m:s 'GMT' y")
Is there a SAS informat that directly reads the string?
First, I would say that you need to describe what you mean by "ANYDTDTM. informat does not properly parse the timestamp from the string.".
This code:
data junk; x= "Wed Apr 30 13:44:54 GMT 2025"; y= input(x,anydtdtm32.); format y datetime20.; run;
yields a value of 30APR2025:13:44:54 for Y, which looks like the "time" was parsed correctly. Note that if you do not provide a width then the informat uses a default width of 19. Your value as shown is 28 characters long. So you need to provide a width at least of 28. There are some cases where the width specified may need to be a few characters longer than the value to work properly, I can't remember an exact value but remember at least a few cases where a width of 32 worked where the value was a bit less and exact width didn't.
If you mean that the Timezone is not included and is what you need then you need to say so.
There are a number of FORMATS that display Timezone offsets. look in the documentation of the various B8601 and E8601 formats.
First, I would say that you need to describe what you mean by "ANYDTDTM. informat does not properly parse the timestamp from the string.".
This code:
data junk; x= "Wed Apr 30 13:44:54 GMT 2025"; y= input(x,anydtdtm32.); format y datetime20.; run;
yields a value of 30APR2025:13:44:54 for Y, which looks like the "time" was parsed correctly. Note that if you do not provide a width then the informat uses a default width of 19. Your value as shown is 28 characters long. So you need to provide a width at least of 28. There are some cases where the width specified may need to be a few characters longer than the value to work properly, I can't remember an exact value but remember at least a few cases where a width of 32 worked where the value was a bit less and exact width didn't.
If you mean that the Timezone is not included and is what you need then you need to say so.
There are a number of FORMATS that display Timezone offsets. look in the documentation of the various B8601 and E8601 formats.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.