I am using SAS Enterprise Guide and I am trying to format a text field by the name of 'Admit Date' with data such as: 20180110164700 to a datetime format. Hopefully formatted to YYYY-MM-DD HH:MM:SS. Any help would be appreciated.
Thank you
Well, in code you do (and this assumes I am right on what the date should be - really a good idea to get the sender to apply some sort of standard date format to the data, something like ISO dates):
data want; set have; mydt=dhms(input(substr(text,1,8),yymmdd8.),input(substr(text,9,2),best.),input(substr(text,10,2),best.),input(substr(text,12,2),best.)); format mydt datetime.; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.