BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

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;
zimcom
Pyrite | Level 9

can I convert it to datetime20. instead of e8601dt25.?

novinosrin
Tourmaline | Level 20

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;
zimcom
Pyrite | Level 9

@novinosrin Thank you so much, it works now.

It did not previously.

 

THANK YOU SO MUCH!!! 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2951 views
  • 2 likes
  • 2 in conversation