Hi,
I have a data,
2020-03-20 13:00:23
2019-04-28 14:18:00
2015-05-20 15:20:30
I want to change to
03/20/2020 13:00:23
04/28/2019 14:18:00
05/20/2015 15:20:30
can you let me know the code.
thank you.
Have a look at the NLDATMS format.
If the date is in character format then you may try the below code
data have; input date&$20.; cards; 2020-03-20 13:00:23 2019-04-28 14:18:00 2015-05-20 15:20:30 ; data want; set have; date2=cat(put(input(scan(date,1,''),yymmdd10.),ddmmyys10.),scan(date,2,'')); run;
To convert from character, use the E8601DT informat:
data have; input datechar $19.; datenum = input(datechar,e8601dt19.); format datenum nldatms19.; datalines; 2020-03-20 13:00:23 2019-04-28 14:18:00 2015-05-20 15:20:30 ;
How the datetime is displayed depends on the setting of the LOCALE= system option.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.