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!!
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!
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.