BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aayushi_17
Quartz | Level 8

what syntax can i use to convert this date format "14MAY2008:00:00:00" to "2008-05-14T00:00" to iso 8601 format ?

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

Are you missing "Seconds" in your required format. Is it supposed to be " 2008-05-14T00:00:00 ". If you don't want the seconds to be included then, then only option will be storing the values as charactes because any 8601 ISO format includes seconds. 

 

If you require seconds too, then use E8601DT19. format if the values are stored as actual date time values. If they are stored as character values then you may need to convert them using INPUT() function.

 

/* If actual values are as character */
data test;
format date E8601DT20.;
date_Char='14MAY2008:00:00:00';
date=INPUT(date_Char,datetime.);

run;

/* Stored as actual date */
data test;
format date E8601DT20.;
date='14MAY2008:00:00:00'dt;
run;

 

Thanks,
Suryakiran

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

All formats and informats are detailed here:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm

 

I would say the first is a datetime informat, the wanted result is an e8601dt format.

SuryaKiran
Meteorite | Level 14

Are you missing "Seconds" in your required format. Is it supposed to be " 2008-05-14T00:00:00 ". If you don't want the seconds to be included then, then only option will be storing the values as charactes because any 8601 ISO format includes seconds. 

 

If you require seconds too, then use E8601DT19. format if the values are stored as actual date time values. If they are stored as character values then you may need to convert them using INPUT() function.

 

/* If actual values are as character */
data test;
format date E8601DT20.;
date_Char='14MAY2008:00:00:00';
date=INPUT(date_Char,datetime.);

run;

/* Stored as actual date */
data test;
format date E8601DT20.;
date='14MAY2008:00:00:00'dt;
run;

 

Thanks,
Suryakiran
Aayushi_17
Quartz | Level 8

Thank you so much all

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 5874 views
  • 0 likes
  • 3 in conversation