Dear community,
I have a read in date and time field as below
XNDAT | XNTIM |
Jun 7 2015 12:00AM | 17:53:00 |
of which XNDAT is 'Text ' and XNTIM as 'Num'
How can I combine them into a long SAS datetime
Your help is greatly appreciated and thank you
new SAS learner
zimcom
data w;
k='Jun 7 2015 12:00AM';
k1='17:53:00't;
k2=input(k,anydtdte20.);
k3=dhms(k2,0,0,0)+k1;
format k3 datetime20.;
run;
data w;
k='Jun 7 2015 12:00AM';
k1='17:53:00't;
k2=input(k,anydtdte20.);
k3=dhms(k2,0,0,0)+k1;
format k3 datetime20.;
run;
It works perfect, you are the best!
Thank you so much!!
zimcom
one more quetion, how to deal with these data below, combine then into one SAS long date?
XTDAT | XTTIM |
Jun 7 2015 12:00AM | 1/1/0001 6:15:00 PM |
Thank you!
data w;
k='Jun 7 2015 12:00AM';
k1='1/1/0001 6:15:00 PM';
k2=input(k,anydtdte20.);
k3=input(k1,anydtdtm21.);
k4=dhms(k2,0,0,0)+timepart(k3);
format k2 date9. k3 k4 datetime20.;
run;
slight correction to the above:
data w;
k='Jun 7 2015 12:00AM';
k1='1/1/0001 6:15:00 PM';
k2=input(k,anydtdtm21.);
k3=input(k1,anydtdtm21.);
k4=k2+timepart(k3);
format k2 date9. k3 k4 datetime20.;
run;
you are absolutely awesome and helpful!!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.