Hi all,
I have a date and time fields, both are Text data type
C_Date looks like 18/06/19 (YY/MM/DD)
C_Time looks like 12:30:48
I need to convert the above 2 text fields into one DateTime field (datetime20.), like 19JUN2019:12:30:48
Thank you!!
data test;
C_Date='18/06/19';
C_Time='12:30:48';
N_date=input(c_date, yymmdd8.);
N_time=input(c_time, time8.);
N_datetime=dhms(N_date,0,0,0)+N_time;
format N_datetime datetime20.;
run;
data test;
C_Date='18/06/19';
C_Time='12:30:48';
N_date=input(c_date, yymmdd8.);
N_time=input(c_time, time8.);
N_datetime=dhms(N_date,0,0,0)+N_time;
format N_datetime datetime20.;
run;
In a data step this should work.
cdt = dhms(input(c_date,yymmdd8.),0,0,input(c_time,time8.));
format cdt datetime18.;
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 save with the early bird rate—just $795!
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.