Help using Base SAS procedures

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

Reply
N/A
Posts: 0

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

hi,

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,174

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

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 site:sas.com

dhms function site:sas.com
Ask a Question
Discussion stats
  • 1 reply
  • 112 views
  • 0 likes
  • 2 in conversation