BookmarkSubscribeRSS Feed
Gary_Z
Fluorite | Level 6

What is the SAS datetime informat for the datetime value of 2021/08/19 18:00:54+00? 

I have tried the ISO8601 datetime informat and datetime20. format but that does not work.

The column is a double and has a date format but all the values in the column are NaT

I am using SAS Viya for Python

3 REPLIES 3
Reeza
Super User
You say the column is a double and has a date format. Is that the new column or original column? This is a datetime, so should have a datetime format as well.
Gary_Z
Fluorite | Level 6

Yes the new column does. I wanted to convert to show up as a Date format only. No time. However I can't find the right datetime informat so I can load the data into CAS with the informat and format in one step at the beginning.

Since I can't find the informat or it doesn't exist I have to extract the first part then use an informat that is known but that requires more steps.

Reeza
Super User

If you just want the date component, read it with a date informat and limit the character count - see the want_date variable. 

This does not read the time zone component correctly, but gets you close.

 

data want;
have = '2021/08/19 18:00:54+04';
change_look = trim(translate(have, '-T', '/ '));
want = input(change_look, E8601DT.);
want_date = input(have, yymmdd10.);
format want datetime22. want_date date9.;
run;

proc print;run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 598 views
  • 0 likes
  • 2 in conversation