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!!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.