Dear All,
I need to convert the Character ISO datetime into datetime format in sas.
Here is the character datetime format.
2022-06-10T09:23:45+5:30
Thanks,
Narahari
Hi,
Please have a look at the SAS doc on ISO 8601 (in)formats.
Your code would look something like this:
data _null_;
format dt datetime21.;
string = '2022-06-10T09:23:45+05:30';
dt = input(string, e8601dz25.);
put string= dt=;
cards;
run;
In my haste I could not get it to work without 0-prefixing the time zone. This may very well be the way ISO wants it. If I read the wiki on ISO 8601 I think I am right and it should be "+05:30".
Hope this helps,
- Jan.
Hi,
Please have a look at the SAS doc on ISO 8601 (in)formats.
Your code would look something like this:
data _null_;
format dt datetime21.;
string = '2022-06-10T09:23:45+05:30';
dt = input(string, e8601dz25.);
put string= dt=;
cards;
run;
In my haste I could not get it to work without 0-prefixing the time zone. This may very well be the way ISO wants it. If I read the wiki on ISO 8601 I think I am right and it should be "+05:30".
Hope this helps,
- Jan.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.