BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
harigottala0
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

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.

View solution in original post

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1086 views
  • 2 likes
  • 2 in conversation