what syntax can i use to convert this date format "14MAY2008:00:00:00" to "2008-05-14T00:00" to iso 8601 format ?
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;
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.
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;
Thank you so much all
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!
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.