<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculating the duration of time between two columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/621316#M182650</link>
    <description>&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I managed to use the following code which gave me the outcome I was after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data set consisted of a&amp;nbsp;&lt;STRONG&gt;start_date&lt;/STRONG&gt; column, a &lt;STRONG&gt;start_time&lt;/STRONG&gt;&amp;nbsp;column, and an&amp;nbsp;&lt;STRONG&gt;end_time&lt;/STRONG&gt; column.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; mydata_set_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;set&amp;nbsp;&lt;/STRONG&gt;mydata_set;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; drop&amp;nbsp;&lt;/STRONG&gt;start_date enddate end_time start_time;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; START_DT=dhms(eventdate,0,0,modestart;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;format&lt;/STRONG&gt; START_DT datetime.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;if&amp;nbsp;&lt;/STRONG&gt;end_time&amp;lt;start_time&amp;nbsp;&lt;STRONG&gt;then&amp;nbsp;&lt;/STRONG&gt;enddate=eventdate+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;else&lt;/STRONG&gt;&amp;nbsp;enddate=eventdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;format&amp;nbsp;&lt;/STRONG&gt;enddate date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; END_DT=dhms(enddate,0,0,modeend);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;format&amp;nbsp;&lt;/STRONG&gt;END_DT datetime.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DURATION=END_DT-START_DT;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jan 2020 21:53:10 GMT</pubDate>
    <dc:creator>justine05</dc:creator>
    <dc:date>2020-01-30T21:53:10Z</dc:date>
    <item>
      <title>Calculating the duration of time between two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/604006#M175055</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS programming in SAS EG.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add a duration column which calculates the duration between two time columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently using the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; duration&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set&lt;/STRONG&gt; mydata_table&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;BR /&gt;DURATION=end_time-start_time&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the type of results I get&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;row&amp;nbsp;&lt;/STRONG&gt; |&amp;nbsp; &lt;STRONG&gt;start_time&lt;/STRONG&gt;&amp;nbsp; |&amp;nbsp; &lt;STRONG&gt;end_time&lt;/STRONG&gt;&amp;nbsp; |&amp;nbsp; &lt;STRONG&gt;duration&lt;/STRONG&gt;&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; 11:05:19&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; 12:00:43&amp;nbsp; &amp;nbsp;|&amp;nbsp; 3324&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; 12:00:43&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 4:19:25&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; -27678&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the output of duration to be in seconds for all rows in the data set&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and where the time goes into the following day as per row 2, I would like it to calculate the actual duration from one day to the next rather than displaying in a negative value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope you can help.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 02:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/604006#M175055</guid>
      <dc:creator>justine05</dc:creator>
      <dc:date>2019-11-14T02:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the duration of time between two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/604008#M175056</link>
      <description>&lt;P&gt;If you wish to have date differences as well then you need to add dates to your input data, either as separate date variables or you could combine them with your time variables as datetimes.There is no way of telling from your row 2 if the end time is for the next day, next week, or next month.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 02:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/604008#M175056</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-11-14T02:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the duration of time between two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/621316#M182650</link>
      <description>&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I managed to use the following code which gave me the outcome I was after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data set consisted of a&amp;nbsp;&lt;STRONG&gt;start_date&lt;/STRONG&gt; column, a &lt;STRONG&gt;start_time&lt;/STRONG&gt;&amp;nbsp;column, and an&amp;nbsp;&lt;STRONG&gt;end_time&lt;/STRONG&gt; column.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; mydata_set_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;set&amp;nbsp;&lt;/STRONG&gt;mydata_set;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; drop&amp;nbsp;&lt;/STRONG&gt;start_date enddate end_time start_time;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; START_DT=dhms(eventdate,0,0,modestart;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;format&lt;/STRONG&gt; START_DT datetime.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;if&amp;nbsp;&lt;/STRONG&gt;end_time&amp;lt;start_time&amp;nbsp;&lt;STRONG&gt;then&amp;nbsp;&lt;/STRONG&gt;enddate=eventdate+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;else&lt;/STRONG&gt;&amp;nbsp;enddate=eventdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;format&amp;nbsp;&lt;/STRONG&gt;enddate date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; END_DT=dhms(enddate,0,0,modeend);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;format&amp;nbsp;&lt;/STRONG&gt;END_DT datetime.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DURATION=END_DT-START_DT;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 21:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-duration-of-time-between-two-columns/m-p/621316#M182650</guid>
      <dc:creator>justine05</dc:creator>
      <dc:date>2020-01-30T21:53:10Z</dc:date>
    </item>
  </channel>
</rss>

