BookmarkSubscribeRSS Feed
Ken_oy
Fluorite | Level 6
I have a variable "date" and a "time" for each patient.
I want to merge them to one variable "date and time", is any way I can do that?

Thanks! Message was edited by: Ken_oy
3 REPLIES 3
data_null__
Jade | Level 19
Are they SAS dates and times?

If so then you just need to convert them to the proper units and add them together.

[pre]datetime = dhms(date,0,0,time);[/pre]

Is commonly used.
Ken_oy
Fluorite | Level 6
Thanks for your quick reply.

I test the code from you, it works for SAS date and SAS time.

But my problem is, I have character variables instead, all strings

i.g.: "date"="01/01/2007"; "time"="13:00:00"

How to transfer all these strings into a SAS date9. format? thanks!
Ken_oy
Fluorite | Level 6
OK, for now I fixed it with your help.

1. transfer those strings into a SAS date:

sas_date=input(substr(string_date, 1, 10), mmddyy10.);

2. using data_null_'s code:

it works now!

Thanks!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1765 views
  • 0 likes
  • 2 in conversation