<?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: continuous period with a gap in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/continuous-period-with-a-gap/m-p/429743#M106167</link>
    <description>&lt;P&gt;Here's one approach, assuming your data set is already sorted:&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 memb_id;&lt;/P&gt;
&lt;P&gt;dif_date = dif(enroll_yrmo);&lt;/P&gt;
&lt;P&gt;month = mod(enroll_yrmo, 100);&lt;/P&gt;
&lt;P&gt;if first.memb_id then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; group=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; return;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if month &amp;gt; 1 and dif_date=1 then return;&lt;/P&gt;
&lt;P&gt;if month=1 and dif_date=89 then return;&lt;/P&gt;
&lt;P&gt;group + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you described the result, but didn't illustrate it, here's what this is doing.&amp;nbsp; It assumes that a "gap" means that a year/month is missing from the sequence (for the same value of MEMB_ID).&amp;nbsp; It creates a new variable (GROUP) that is 1 for the first set of sequential observations, but increases whenever a gap is found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2018 19:02:45 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-01-22T19:02:45Z</dc:date>
    <item>
      <title>continuous period with a gap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/continuous-period-with-a-gap/m-p/429739#M106163</link>
      <description>&lt;P&gt;I am looking for some help on creating a macro that will identify continuous enrollment with a given gap. For example, we will allow a month gap and still allow continuous enrollment. The data structure I have is....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Memb_id enroll_yrmo (number - not date)&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 201701&lt;/P&gt;&lt;P&gt;1 201702&lt;/P&gt;&lt;P&gt;1 201703&lt;/P&gt;&lt;P&gt;1 201704&lt;/P&gt;&lt;P&gt;1 201705&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;1 201712&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done this before but it was with from and thru dates with a single record per member. Now, I have a record for every month and it isn't even a date. It is a number. I would love your help and input.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/continuous-period-with-a-gap/m-p/429739#M106163</guid>
      <dc:creator>JDonovan</dc:creator>
      <dc:date>2018-01-22T18:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: continuous period with a gap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/continuous-period-with-a-gap/m-p/429743#M106167</link>
      <description>&lt;P&gt;Here's one approach, assuming your data set is already sorted:&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 memb_id;&lt;/P&gt;
&lt;P&gt;dif_date = dif(enroll_yrmo);&lt;/P&gt;
&lt;P&gt;month = mod(enroll_yrmo, 100);&lt;/P&gt;
&lt;P&gt;if first.memb_id then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; group=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; return;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if month &amp;gt; 1 and dif_date=1 then return;&lt;/P&gt;
&lt;P&gt;if month=1 and dif_date=89 then return;&lt;/P&gt;
&lt;P&gt;group + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you described the result, but didn't illustrate it, here's what this is doing.&amp;nbsp; It assumes that a "gap" means that a year/month is missing from the sequence (for the same value of MEMB_ID).&amp;nbsp; It creates a new variable (GROUP) that is 1 for the first set of sequential observations, but increases whenever a gap is found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 19:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/continuous-period-with-a-gap/m-p/429743#M106167</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-22T19:02:45Z</dc:date>
    </item>
  </channel>
</rss>

