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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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