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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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