<?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: 3 month continuous eligibilities in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322858#M62045</link>
    <description>&lt;P&gt;It helps to show what the expected output would look like.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2017 00:18:12 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-01-06T00:18:12Z</dc:date>
    <item>
      <title>3 month continuous eligibilities</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322848#M62044</link>
      <description>&lt;P&gt;Hi everyone, need help coding&amp;nbsp;whether the individual has been there 3 months back to back(jan-mar or feb-apr) for the year. If there are gaps, dont pull include this individuals. &amp;nbsp;Example below: Individual AA is there from jan-mar contionously so we include him, individual BB has gap so dont include him. Could someone provide any ideas which may help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Individual &amp;nbsp;Date&lt;BR /&gt;AA &amp;nbsp;1/1/2016&lt;BR /&gt;AA &amp;nbsp;2/1/2016&lt;BR /&gt;AA &amp;nbsp;3/1/2016&lt;BR /&gt;AA &amp;nbsp;4/1/2016&lt;BR /&gt;AA &amp;nbsp;7/1/2016&lt;BR /&gt;AA &amp;nbsp;8/1/2016&lt;BR /&gt;AA &amp;nbsp;12/1/2016&lt;BR /&gt;BB &amp;nbsp;2/1/2016&lt;BR /&gt;BB &amp;nbsp;4/1/2016&lt;BR /&gt;BB &amp;nbsp;5/1/2016&lt;BR /&gt;BB &amp;nbsp;7/1/2016&lt;BR /&gt;BB &amp;nbsp;8/1/2016&lt;BR /&gt;CC 6/1/2016&lt;BR /&gt;CC 7/1/2016&lt;BR /&gt;CC 8/1/2016&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 23:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322848#M62044</guid>
      <dc:creator>RonLee</dc:creator>
      <dc:date>2017-01-05T23:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: 3 month continuous eligibilities</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322858#M62045</link>
      <description>&lt;P&gt;It helps to show what the expected output would look like.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 00:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322858#M62045</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-06T00:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: 3 month continuous eligibilities</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322862#M62047</link>
      <description>&lt;P&gt;&lt;BR /&gt;If the desired output could be similiar to this, that would be awesome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Individual Type&lt;/P&gt;&lt;P&gt;AA continuous&lt;/P&gt;&lt;P&gt;BB not_continuous&lt;/P&gt;&lt;P&gt;CC continuous&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 00:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322862#M62047</guid>
      <dc:creator>RonLee</dc:creator>
      <dc:date>2017-01-06T00:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: 3 month continuous eligibilities</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322873#M62049</link>
      <description>&lt;P&gt;If your requirement is that the individual should have had three contiguous months,&amp;nbsp;&lt;EM&gt;ever&lt;/EM&gt;, then this will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data source;
infile cards;
attrib individual length=$ 2;
attrib date informat=mmddyy10. format=monyy7.;
input individual 
      date;
cards;
AA  1/1/2016
AA  2/1/2016
AA  3/1/2016
AA  4/1/2016
AA  7/1/2016
AA  8/1/2016
AA  12/1/2016
BB  2/1/2016
BB  4/1/2016
BB  5/1/2016
BB  7/1/2016
BB  8/1/2016
CC 6/1/2016
CC 7/1/2016
CC 8/1/2016
;
run;

data result;
set source;
by individual;
attrib save_date length=4 format=monyy7.;
retain count save_date;
if first.individual 
   then do;
        count = 1;                               /* On the first time, there will always be one! */
        call missing(save_date);     
        end;
   else do;
        if intck('month', save_date, date) = 1   /* Is there a one-month gap? */
           then count + 1;                       /* Increment */
           else count = 1;                       /* Otherwise reset */
        end;
save_date = date;                                /* Save the current observation's date */
if last.individual or count ge 3;                /* Last in the group, or continuous */
if count &amp;lt; 3
   then status = 0;
   else status = 1;
keep individual status;
run;

proc sql;
create table result_summ as
   select individual,
          ifc(max(status) = 1, 'continuous', 'non-continuous') as status_text length=14
     from result
    group by individual;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that it requires two passes - one to flag any three continuous months as &lt;EM&gt;1&lt;/EM&gt; (or&amp;nbsp;&lt;EM&gt;0&lt;/EM&gt; if they're not contiguous), then the sql pass to get the maximum value of the status. The&amp;nbsp;&lt;EM&gt;ifc&lt;/EM&gt; function returns either of the two text strings, depending on the truth of the condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at&amp;nbsp;&lt;EM&gt;AA&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;: there are three sets of months, Jan/Mar, Feb/Apr and the last three (non-continuous). This creates three observations in&amp;nbsp;&lt;EM&gt;result&lt;/EM&gt;, the first pass, with respective values in&amp;nbsp;&lt;EM&gt;status&lt;/EM&gt; of&amp;nbsp;&lt;EM&gt;1&lt;/EM&gt;,&amp;nbsp;&lt;EM&gt;1&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;0.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 01:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/322873#M62049</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-06T01:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: 3 month continuous eligibilities</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/323129#M62067</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;:&lt;BR /&gt;Thank you so much, this works perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 06 Jan 2017 23:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/3-month-continuous-eligibilities/m-p/323129#M62067</guid>
      <dc:creator>RonLee</dc:creator>
      <dc:date>2017-01-06T23:30:21Z</dc:date>
    </item>
  </channel>
</rss>

