<?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: Fast way to calculate time in minutes over two days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38892#M7863</link>
    <description>Why not use function abs(), which will always give you a positive value!</description>
    <pubDate>Tue, 22 Jun 2010 07:59:17 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2010-06-22T07:59:17Z</dc:date>
    <item>
      <title>Fast way to calculate time in minutes over two days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38888#M7859</link>
      <description>I have a huge dataset in which a procedure was started at 23:00 and finished at 02:00 (for example) and I need to calculate how many minutes for the procedure.  Every method I use gives me negative values.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?  I've searched the internet for help with no success so far.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance!</description>
      <pubDate>Mon, 21 Jun 2010 21:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38888#M7859</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-06-21T21:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to calculate time in minutes over two days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38889#M7860</link>
      <description>Does your data also record a start date and finish date? If so then you can combine the dates and times to get what you want like so:&lt;BR /&gt;
&lt;BR /&gt;
start date time = dhms(start date,start hh,start mm, start ss);&lt;BR /&gt;
end date time = dhms(end date,end hh,e nd mm, end ss);&lt;BR /&gt;
duration = end date time - start date time;&lt;BR /&gt;
format duration datetime. ;&lt;BR /&gt;
&lt;BR /&gt;
If you don't have start and finish dates then its a bit harder. Can a procedure last more than one day? If yes then you have a problem! If not then you can assume if end is less than start then it has gone over just one day boundary:&lt;BR /&gt;
&lt;BR /&gt;
if end time &amp;lt; start time then duration = end time + 24 - start time;&lt;BR /&gt;
else  duration = end time - start time;</description>
      <pubDate>Mon, 21 Jun 2010 23:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38889#M7860</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2010-06-21T23:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to calculate time in minutes over two days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38890#M7861</link>
      <description>Have a look at the INTCK function while more importantly working with SAS DATETIME variables in your computation.  SAS Language DOC and the SAS support website have reference material and SAS coding examples -search on these terms.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic/post:&lt;BR /&gt;
&lt;BR /&gt;
data step datetime variables intck site:sas.com</description>
      <pubDate>Tue, 22 Jun 2010 02:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38890#M7861</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-06-22T02:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to calculate time in minutes over two days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38891#M7862</link>
      <description>rather than use time values, use datetime() function to indicate a point in time. The difference of the values returned from the datetime() function will provide a duration in seconds that will present well with format  mmss11.2&lt;BR /&gt;
%let starting_at= %sysfunc( datetime(), 20.3) ;&lt;BR /&gt;
 * your long procedure follows ;&lt;BR /&gt;
%let finishing_at = %sysfunc( datetime(), 20.3) ;&lt;BR /&gt;
&lt;BR /&gt;
%put duration of long procedure was %sysfunc( range( &amp;amp;starting_at, &amp;amp;finishing_at), mmss11.2 ) ;&lt;BR /&gt;
 &lt;BR /&gt;
Demonstrated in this clip from a SASlog[pre]1    %let starting_at= %sysfunc( datetime(), 20.3) ;&lt;BR /&gt;
2     * your long procedure follows ;&lt;BR /&gt;
3      %put waiting %sysfunc( sleep(1234, .001 ));&lt;BR /&gt;
waiting 0.001&lt;BR /&gt;
4    %let finishing_at = %sysfunc( datetime(), 20.3) ;&lt;BR /&gt;
5&lt;BR /&gt;
6    %put duration of long procedure was %sysfunc( range( &amp;amp;starting_at, &amp;amp;finishing_at), mmss11.2 ) ;&lt;BR /&gt;
duration of long procedure was     0:01.31[/pre]</description>
      <pubDate>Tue, 22 Jun 2010 07:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38891#M7862</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-06-22T07:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to calculate time in minutes over two days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38892#M7863</link>
      <description>Why not use function abs(), which will always give you a positive value!</description>
      <pubDate>Tue, 22 Jun 2010 07:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38892#M7863</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-06-22T07:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to calculate time in minutes over two days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38893#M7864</link>
      <description>Thanks to everyone for your suggestions.&lt;BR /&gt;
&lt;BR /&gt;
I finally figured out something last night before I had a chance to check back here.  I just used a calculation.&lt;BR /&gt;
&lt;BR /&gt;
timeactive=(('24:00't-ltime)+ltime2)/60;&lt;BR /&gt;
&lt;BR /&gt;
ltime=the time before midnight &lt;BR /&gt;
ltime2= the time after midnight.&lt;BR /&gt;
&lt;BR /&gt;
I decided not to incorporate the dates since the time span should never be longer than 8 hours, so there will only be two days involved.&lt;BR /&gt;
&lt;BR /&gt;
I will consider datetime in the future if it will span more days.</description>
      <pubDate>Tue, 22 Jun 2010 13:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fast-way-to-calculate-time-in-minutes-over-two-days/m-p/38893#M7864</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-06-22T13:10:46Z</dc:date>
    </item>
  </channel>
</rss>

