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.
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.