<?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: looking for gaps in time spans for each memberID with multiple rows per memberID in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/517799#M3421</link>
    <description>&lt;P&gt;Assuming your data set is sorted as indicated, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;gap_size = start_date - lag(end_date);&lt;/P&gt;
&lt;P&gt;if first.id = 0 and gap_size &amp;gt; 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you only the observations that begin after a gap.&amp;nbsp; If you want all the records, you could use a similar variation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;gap_size = start_time - lag(end_date);&lt;/P&gt;
&lt;P&gt;if first.id then gap_size = 0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the examples you gave, there is no gap when gap_size is either 0 or 1.&lt;/P&gt;</description>
    <pubDate>Sun, 02 Dec 2018 03:46:25 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-12-02T03:46:25Z</dc:date>
    <item>
      <title>looking for gaps in time spans for each memberID with multiple rows per memberID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/517786#M3416</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a list of members that can be enrolled in a club. Some members stay continuously enrolled, while other stop and start.&amp;nbsp; I'm trying to find those members who stopped&amp;nbsp; during the year and then re-enrolled and how long the gap is.&amp;nbsp; Each time a member re-enrolls, a new record is created. So some members will only have one record, but other could have 4 or 5 records.&amp;nbsp; In the example below, I have members for just one year, but the records go back for three to four years.&amp;nbsp; Any suggestions?&amp;nbsp; Would an array work?&amp;nbsp; I thought about transpose, but there are over 80,000 records.&amp;nbsp; I tried a retain function to come up with one row per member, but I couldn't get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the&amp;nbsp; example below ,member 111 has 12 continuous months, but member 122 has a one month gap.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;ID Start_Date End_Date&lt;BR /&gt;111 01/01/2017 12/31/2017&lt;BR /&gt;122 01/01/2017 06/30/2017&lt;BR /&gt;122 08/01/2017 12/31/2017&lt;BR /&gt;133 01/01/2017 06/30/2017&lt;BR /&gt;133 07/01/2017 12/31/2017&lt;BR /&gt;144 1/1/2017 02/28/2017&lt;BR /&gt;144 04/01/2017 06/30/2017&lt;BR /&gt;144 08/01/2017 10/31/2017&lt;BR /&gt;144 11/01/2017 12/31/2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 00:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/517786#M3416</guid>
      <dc:creator>abqdiane</dc:creator>
      <dc:date>2018-12-02T00:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: looking for gaps in time spans for each memberID with multiple rows per memberID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/517799#M3421</link>
      <description>&lt;P&gt;Assuming your data set is sorted as indicated, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;gap_size = start_date - lag(end_date);&lt;/P&gt;
&lt;P&gt;if first.id = 0 and gap_size &amp;gt; 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you only the observations that begin after a gap.&amp;nbsp; If you want all the records, you could use a similar variation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;gap_size = start_time - lag(end_date);&lt;/P&gt;
&lt;P&gt;if first.id then gap_size = 0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the examples you gave, there is no gap when gap_size is either 0 or 1.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 03:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/517799#M3421</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-02T03:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: looking for gaps in time spans for each memberID with multiple rows per memberID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/518509#M3568</link>
      <description>&lt;P&gt;Thanks so much -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 18:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/looking-for-gaps-in-time-spans-for-each-memberID-with-multiple/m-p/518509#M3568</guid>
      <dc:creator>abqdiane</dc:creator>
      <dc:date>2018-12-04T18:12:37Z</dc:date>
    </item>
  </channel>
</rss>

