<?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: Summary of Minutes per Day Between Two DateTime values? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658204#M197260</link>
    <description>&lt;P&gt;So the method I use typically is the same as yours, expand to daily and then summarize via PROC FREQ. But I think&amp;nbsp;@freelanceReinhard has a solution that doesn't do that. Or maybe&amp;nbsp;@novinsrin &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That one is cumbersome and inefficient. I'm fairly certain he's posted one for days but not sure about day times.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jun 2020 20:25:58 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-12T20:25:58Z</dc:date>
    <item>
      <title>Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658130#M197250</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to calculate the minutes per day between two date/time values.&amp;nbsp; For the first card below, the resulting data with one line per day for each chartno and acctno:&lt;/P&gt;
&lt;P&gt;4/1/19&amp;nbsp;- 111111 121212 960 minutes&lt;/P&gt;
&lt;P&gt;4/2/19 - 111111 121212 1440 minutes&lt;/P&gt;
&lt;P&gt;4/3/19 - 111111 121212&amp;nbsp; 900 minutes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data grp1;
input @1  chartno 	$6.
	  @7  acctno  	$6.
	  @13 admdate   mmddyy10.
	  @23 disdate   mmddyy10.
	  @33 icuadmdttm  anydtdtm.
	  @49 icudisdttm  anydtdtm.
	  ;
	  
cards;
111111 12121204/01/201904/10/201901Apr19 08:00:0003Apr19 15:00:00
11111112121204/01/201904/10/201907Apr19 13:00:0010Apr19 13:00:00
55555516161608/01/201908/13/201901Aug19 08:00:0005Aug19 11:30:00
55555516161608/01/201908/13/201910Aug19 15:35:0013Aug19 10:00:00
run; 

&lt;/PRE&gt;
&lt;P&gt;Any and all assistance greatly appreciated, thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 17:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658130#M197250</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2020-06-12T17:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658131#M197251</link>
      <description>&lt;P&gt;INTCK with minutes + LAG() to get previous value if it's across rows.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/INTCK-to-compute-minutes-between-dates/td-p/386324" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/General-SAS-Programming/INTCK-to-compute-minutes-between-dates/td-p/386324&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS/ETS PROC TIMESERIES is also an option.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 17:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658131#M197251</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-12T17:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658181#M197252</link>
      <description>&lt;P&gt;Hey Reeza!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your response.&amp;nbsp; I am not sure how I would use the LAG because I'm not understanding why I would be accessing a previous value?&amp;nbsp; Can you please explain further?&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 19:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658181#M197252</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2020-06-12T19:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658182#M197253</link>
      <description>I don't know if you need it. If you're just doing difference between the variables in the same row you don't need it. If you are crossing rows you would need it.&lt;BR /&gt;&lt;BR /&gt;The data kinda runs together in your post so I didn't do the mental arithmetic to see how your desired answer aligns with the data you provided (I'm being lazy). INTCK() is likely all you need &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 12 Jun 2020 19:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658182#M197253</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-12T19:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658183#M197254</link>
      <description>&lt;P&gt;I think you are right but not sure how to accomplish this.&amp;nbsp; I basically want an occupancy report but instead of just dates I would want date/times so that I can calculate total minutes per each day of occupancy in the ICU.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original report for occupancy using ICU dates is a do loop where do=icuadmdate to icudisdate-1;&amp;nbsp; In this instance I assume I want to first create the datetime fields and then create the calculation for the minutes.&amp;nbsp; I'm just not clear how I do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 19:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658183#M197254</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2020-06-12T19:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658188#M197257</link>
      <description>Are you doing this just so you can count days overall? You can do that or there's another approach if that's what you're doing. Or do you want a record per day for another reason?&lt;BR /&gt;&lt;BR /&gt;This is an occupancy report or the 'medicine cabinet' problem - how many drugs (patients in your case) do you have at x time in the medicine cabinet (ICU or some location in your case).</description>
      <pubDate>Fri, 12 Jun 2020 19:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658188#M197257</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-12T19:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658202#M197259</link>
      <description>&lt;P&gt;Hi Reeza&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finance wants to know how many minutes per day utilized by patients in the ICU per each day for a case costing exercise.&amp;nbsp; &amp;nbsp;So whereas occupancy allows us to create a record per day between admit and discharge date, I would like minutes related to the icu admit date/time per each day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, for the first example, there would be 3 days showing (Apr 1 to 3) and the minutes would be calculated as 0800 hours to midnight (960 minutes) for April 1 because the patient entered the ICU at 0800, then the full day of April 2 = 1440 minutes, then day 3 would be 00:01 to 1500 hours (900 minutes) where 1500 is when they are discharged from ICU.&amp;nbsp; These would be 3 rows of data for the same chartno/acctno.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 20:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658202#M197259</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2020-06-12T20:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658204#M197260</link>
      <description>&lt;P&gt;So the method I use typically is the same as yours, expand to daily and then summarize via PROC FREQ. But I think&amp;nbsp;@freelanceReinhard has a solution that doesn't do that. Or maybe&amp;nbsp;@novinsrin &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That one is cumbersome and inefficient. I'm fairly certain he's posted one for days but not sure about day times.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 20:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658204#M197260</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-12T20:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658205#M197261</link>
      <description>&lt;P&gt;Here is one way. Note that I changed the informat on the first date time value because with no delimiter and no specified length for the informat it was reading the day of the second datetime value as part of the seconds in the first.&lt;/P&gt;
&lt;PRE&gt;data want;
   set grp1;
   basetime = icuadmdttm;
   do while (basetime &amp;lt; icudisdttm);
      minutes = intck('minute',basetime,min(intnx('dtday',basetime,1,'B'), icudisdttm));
      output;
      basetime=intnx('dtday',basetime,1,'B');
   end;
   format basetime datetime20.;
run;&lt;/PRE&gt;
&lt;P&gt;It took be a bit to figure out that you want the individual days "contribution" as a separate record (I think) with the minute counts.&lt;/P&gt;
&lt;P&gt;Key here is the INTNX to advance a current date time to the beginning of the next interval (if you use end of the current interval minutes are short by one) and using the earlier of the advanced datetime or the end of the period in the other variable. Then using the INTCK function to get the values between.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basic "do while" stuff of resetting the loop control variable .&lt;/P&gt;
&lt;P&gt;You can likely drop at least the basetime variable but this way you can look at how the values change. Since the OUTPUT comes before the basetime reassignment you see the value at the start of each loop in the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 20:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658205#M197261</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-12T20:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Summary of Minutes per Day Between Two DateTime values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658211#M197265</link>
      <description>&lt;P&gt;Thanks to the both of you for your speedy response!&amp;nbsp; Ballardw's solution works exactly as I required, thank you so much!&amp;nbsp; Have a great weekend everyone!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 20:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-of-Minutes-per-Day-Between-Two-DateTime-values/m-p/658211#M197265</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2020-06-12T20:46:25Z</dc:date>
    </item>
  </channel>
</rss>

