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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register 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.

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