<?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: How can I combine uses within 25 minutes of each other? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855856#M338205</link>
    <description>&lt;P&gt;Some details to consider before solution. Suppose, just for an example, that you have 10 records at 5 minute intervals. The first six wold be within 25 minutes of the first. The 7th would within 25 minutes of the second, and similar overlapping intervals of 25 minutes would occur. So would the 7th start a "new" interval period? Or would the overlap with 2,3,4,5 and 6 have to be considered in the final result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please walk us through all of the steps that you go through to get lines 1 and 2 condensed to 60 minutes. I am afraid I don't see where 60 comes from at all.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jan 2023 21:38:18 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-01-26T21:38:18Z</dc:date>
    <item>
      <title>How can I combine uses within 25 minutes of each other?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855847#M338203</link>
      <description>&lt;P&gt;Hi all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that tracks each time a person uses an electronic device and the how long they use the device for. I need to combine uses per person that occur within 25 minutes of each other and sum the duration for all uses within that timeframe. So far this is how I set up my data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id=participant&lt;/P&gt;&lt;P&gt;duration=time using device&lt;/P&gt;&lt;P&gt;date1=date used device&lt;/P&gt;&lt;P&gt;time1=time used device&lt;/P&gt;&lt;P&gt;date2=date of next use&lt;/P&gt;&lt;P&gt;time2=time of next use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need would be to collapse observations, for each person, that are within 25 minutes of the first use (on the same day) and add the durations. So here line 2 and 3 would be combined for 60 minutes since they are on the same day and the times are within 25 minutes of each other.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;duration (minutes)&lt;/TD&gt;&lt;TD&gt;date1&lt;/TD&gt;&lt;TD&gt;time1&lt;/TD&gt;&lt;TD&gt;date2&lt;/TD&gt;&lt;TD&gt;time2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;12/21/2021&lt;/TD&gt;&lt;TD&gt;11:30:47&lt;/TD&gt;&lt;TD&gt;12/23/2021&lt;/TD&gt;&lt;TD&gt;10:38:52&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;12/23/2021&lt;/TD&gt;&lt;TD&gt;10:38:52&lt;/TD&gt;&lt;TD&gt;12/23/2021&lt;/TD&gt;&lt;TD&gt;10:44:45&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;12/23/2021&lt;/TD&gt;&lt;TD&gt;10:44:45&lt;/TD&gt;&lt;TD&gt;12/24/2021&lt;/TD&gt;&lt;TD&gt;16:23:14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;12/24/2021&lt;/TD&gt;&lt;TD&gt;16:23:14&lt;/TD&gt;&lt;TD&gt;12/24/2021&lt;/TD&gt;&lt;TD&gt;16:25:15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 26 Jan 2023 22:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855847#M338203</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2023-01-26T22:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine uses within 25 minutes of each other?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855856#M338205</link>
      <description>&lt;P&gt;Some details to consider before solution. Suppose, just for an example, that you have 10 records at 5 minute intervals. The first six wold be within 25 minutes of the first. The 7th would within 25 minutes of the second, and similar overlapping intervals of 25 minutes would occur. So would the 7th start a "new" interval period? Or would the overlap with 2,3,4,5 and 6 have to be considered in the final result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please walk us through all of the steps that you go through to get lines 1 and 2 condensed to 60 minutes. I am afraid I don't see where 60 comes from at all.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 21:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855856#M338205</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-26T21:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine uses within 25 minutes of each other?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855868#M338206</link>
      <description>&lt;P&gt;Sorry I was making a table with sample data and wrote it out wrong. The correct combination would be lines 2+3 since they are on the same day and within 25 minutes of each other. Use 1 for that day was 45 minutes and use 2 for that day was 15 minutes = 60 minutes total since we want to combine these two as one use.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes that is correct. It should be uses within 25 minutes of the initial use, which is part of why I am having trouble with working through the code. The 7th would start a new interval period.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 22:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855868#M338206</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2023-01-26T22:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine uses within 25 minutes of each other?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855871#M338207</link>
      <description>You don't specify what you want as output? Do you want just another column indicating these are together, to create a new row that shows shows the start time and end time of last sequence?</description>
      <pubDate>Thu, 26 Jan 2023 22:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855871#M338207</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-26T22:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine uses within 25 minutes of each other?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855872#M338208</link>
      <description>&lt;P&gt;Assuming you want the start/end time of the data and it collapsed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data episodes;
set have;
by id; 
retain episode;
if first.id then episode=0;
if duration &amp;gt;25 then episode+1;
run;

proc means data=episodes nway;
by id episode;
var date1 time1;
output out=want min(date1)=start_date min(time1) = start_time max(date2)=end_date max(time2) = end_time;
run;

proc print data=want;
run;
run;



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;untested&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255164"&gt;@fordcr2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset that tracks each time a person uses an electronic device and the how long they use the device for. I need to combine uses per person that occur within 25 minutes of each other and sum the duration for all uses within that timeframe. So far this is how I set up my data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id=participant&lt;/P&gt;
&lt;P&gt;duration=time using device&lt;/P&gt;
&lt;P&gt;date1=date used device&lt;/P&gt;
&lt;P&gt;time1=time used device&lt;/P&gt;
&lt;P&gt;date2=date of next use&lt;/P&gt;
&lt;P&gt;time2=time of next use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I need would be to collapse observations, for each person, that are within 25 minutes of the first use (on the same day) and add the durations. So here line 2 and 3 would be combined for 60 minutes since they are on the same day and the times are within 25 minutes of each other.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;id&lt;/TD&gt;
&lt;TD&gt;duration (minutes)&lt;/TD&gt;
&lt;TD&gt;date1&lt;/TD&gt;
&lt;TD&gt;time1&lt;/TD&gt;
&lt;TD&gt;date2&lt;/TD&gt;
&lt;TD&gt;time2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;30&lt;/TD&gt;
&lt;TD&gt;12/21/2021&lt;/TD&gt;
&lt;TD&gt;11:30:47&lt;/TD&gt;
&lt;TD&gt;12/23/2021&lt;/TD&gt;
&lt;TD&gt;10:38:52&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;45&lt;/TD&gt;
&lt;TD&gt;12/23/2021&lt;/TD&gt;
&lt;TD&gt;10:38:52&lt;/TD&gt;
&lt;TD&gt;12/23/2021&lt;/TD&gt;
&lt;TD&gt;10:44:45&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;TD&gt;12/23/2021&lt;/TD&gt;
&lt;TD&gt;10:44:45&lt;/TD&gt;
&lt;TD&gt;12/24/2021&lt;/TD&gt;
&lt;TD&gt;16:23:14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;12/24/2021&lt;/TD&gt;
&lt;TD&gt;16:23:14&lt;/TD&gt;
&lt;TD&gt;12/24/2021&lt;/TD&gt;
&lt;TD&gt;16:25:15&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 22:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-uses-within-25-minutes-of-each-other/m-p/855872#M338208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-26T22:59:16Z</dc:date>
    </item>
  </channel>
</rss>

