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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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