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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.