Hi all,
I have a sig_Date variable of type YYMMDD10. and a sig_Time variable type TIME5.
Like
sig_Date 2018-09-10
sig_Time 11:22
I want to combine them into 1 variable called sig_DateTime like 2018-09-10 00:11:22 using function
sig_DateTime = dhms(sig_Date,0,0,0)+ sig_Time;
format sig_DateTime is8601da.;
what I got is something like **********
Can someone tell me where I am wrong and I have been using this function for all the data and time to DateTime conversion, it all works well until this one
Thanks as always
Hi @zimcom You are not converting anything here per se. A format doesn't change the value , it only changes how the value is displayed.
So change the format to whatever you want
data w;
sig_Date='10sep2018'd;
sig_Time='11:22't;
sig_DateTime = dhms(sig_Date,0,0,0)+ sig_Time;
format sig_Date date9. sig_Time time5. sig_DateTime datetime20.;
run;
Is this acceptable?
data w;
sig_Date='10sep2018'd;
sig_Time='11:22't;
sig_DateTime = dhms(sig_Date,0,0,0)+ sig_Time;
format sig_Date date9. sig_Time time5. sig_DateTime e8601dt25.;
run;
can I convert it to datetime20. instead of e8601dt25.?
Hi @zimcom You are not converting anything here per se. A format doesn't change the value , it only changes how the value is displayed.
So change the format to whatever you want
data w;
sig_Date='10sep2018'd;
sig_Time='11:22't;
sig_DateTime = dhms(sig_Date,0,0,0)+ sig_Time;
format sig_Date date9. sig_Time time5. sig_DateTime datetime20.;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.