Help using Base SAS procedures

How to add "time" to an existing DateTime value ??

Not applicable
Posts: 0

How to add "time" to an existing DateTime value ??


Just a quick Q, and I can't seem to find examples anywhere of someone doing this but.. the dataset I have has two colums

date_time_start (yyyymmdd hhmmss) and duration (hh:mm:ss)

We have a need to create a new column called date_time_end in yyyymmdd hhmmss that would ultimatly be date_time_start + duration

how would one go about doing this in a data step?
Super Contributor
Super Contributor
Posts: 3,176

Re: How to add "time" to an existing DateTime value ??

Posted in reply to deleted_user
You simply add the two variables together, or you could use the DHMS function and code placeholder "0" values for the "h" and "m" arguments. You are working with a duration that is seconds and your datetime variable is also "seconds...since 1/1/1960". So these two variables are compatible.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

using sas date variables

dhms function
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation