Hello, I have in a string value the date time in this format "2018-09-04T14:11:58.000Z". I've been trying the SAS ISO formats within an INPUT statement but can't identify the correct format from the support documentation SAS ISO Support Documentation
I had some success with the code below
data textstring; iso = '2018-09-04T14:11:58.000Z'; output; iso = '2019-10-01T14:11:58.000Z'; output; iso = '2018-09-04T14:11:58.000Z'; output; iso = '2019-10-01T14:11:58.000Z'; output; iso = '2019-10-01T14:44:42.000Z'; output; run; data t1; set textstring; informat t1 E8601DT16.; format t1 E8601DT16. t2 date9. t3 time5.; t1= input(iso,E8601DT16.); t2=datepart(t1); t3=timepart(t1); run;
See here:
data test;
dt_char = "2018-09-04T14:11:58.000Z";
dt_num = input(dt_char,e8601dz24.);
format dt_num e8601dx32.3;
run;
Result:
1 2018-09-04T14:11:58.000Z 2018-09-04T16:11:58.000+02:00
(Austria, DST)
I had some success with the code below
data textstring; iso = '2018-09-04T14:11:58.000Z'; output; iso = '2019-10-01T14:11:58.000Z'; output; iso = '2018-09-04T14:11:58.000Z'; output; iso = '2019-10-01T14:11:58.000Z'; output; iso = '2019-10-01T14:44:42.000Z'; output; run; data t1; set textstring; informat t1 E8601DT16.; format t1 E8601DT16. t2 date9. t3 time5.; t1= input(iso,E8601DT16.); t2=datepart(t1); t3=timepart(t1); run;
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!
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.