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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.