<?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: Check eligibility based on enrollment info in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848323#M335394</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover dsd;
input DummyID (Enroll_beg_dt Enroll_end_dt) (:date9.);
format Enroll_beg_dt Enroll_end_dt date9.;
datalines;
1,01Jan2017,28Feb2018
1,02Mar2018,31Mar2018
1,02Apr2018,08Jul2018
1,01Aug2018,31Dec2018
2,01Jan2017,07Aug2017
2,03Oct2017,31May2018
2,01Oct2018,30Nov2018
3,01Jan2017,28Feb2018
3,02Mar2018,31Mar2018
3,02Apr2018,31Dec2018
4,01Jan2017,31Dec2018
5,01Oct2017,28Feb2018
6,01Jan2017,28Feb2018
6,02Mar2018,31Mar2018
6,02Apr2018,31Dec2018
7,01Apr2018,05Apr2018
7,01May2018,30Sep2018
7,01Nov2018,31Dec2018
8,01Aug2017,31Aug2017
8,08Sep2017,30Sep2017
8,18Oct2017,31Oct2017
8,08Nov2017,30Nov2017
8,08Dec2017,31Dec2017
8,16Jan2018,31Jan2018
8,02Feb2018,28Feb2018
8,02Mar2018,31Mar2018
8,19Apr2018,30Apr2018
8,09May2018,31May2018
8,14Aug2018,31Aug2018
8,27Sep2018,30Sep2018
8,08Nov2018,30Nov2018
;
run;

data temp;
 set have;
 do date=Enroll_beg_dt to Enroll_end_dt;
  output;
 end;
keep DummyID date;
format date date9.;
run;
proc sort data=temp nodupkey ;by  DummyID date;run;
data temp;
 set temp;
 by DummyID;
 if first.DummyID or dif(date)&amp;gt;60 then group+1;
run;
proc sql;
create table want as
select DummyID,max(n)&amp;gt;365 as Eligible from 
(
select DummyID,group,count(*) as n
 from temp
  group by DummyID,group
)
group by DummyID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Dec 2022 11:47:56 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-12-07T11:47:56Z</dc:date>
    <item>
      <title>Check eligibility based on enrollment info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848273#M335370</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have another task related to enrollment data. In the data I have, each person has one or more enrollment records during the years 2017-2018. I need to identify if a person had at least 365 days of enrollment during the two years, with no more than one gap of maximum 60 days in enrollment. The dummy data is as below:&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input DummyID (Enroll_beg_dt Enroll_end_dt) (:date9.);&lt;BR /&gt;format Enroll_beg_dt Enroll_end_dt date9.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,01Jan2017,28Feb2018&lt;BR /&gt;1,02Mar2018,31Mar2018&lt;BR /&gt;1,02Apr2018,08Jul2018&lt;BR /&gt;1,01Aug2018,31Dec2018&lt;BR /&gt;2,01Jan2017,07Aug2017&lt;BR /&gt;2,03Oct2017,31May2018&lt;BR /&gt;2,01Oct2018,30Nov2018&lt;BR /&gt;3,01Jan2017,28Feb2018&lt;BR /&gt;3,02Mar2018,31Mar2018&lt;BR /&gt;3,02Apr2018,31Dec2018&lt;BR /&gt;4,01Jan2017,31Dec2018&lt;BR /&gt;5,01Oct2017,28Feb2018&lt;BR /&gt;6,01Jan2017,28Feb2018&lt;BR /&gt;6,02Mar2018,31Mar2018&lt;BR /&gt;6,02Apr2018,31Dec2018&lt;BR /&gt;7,01Apr2018,05Apr2018&lt;BR /&gt;7,01May2018,30Sep2018&lt;BR /&gt;7,01Nov2018,31Dec2018&lt;BR /&gt;8,01Aug2017,31Aug2017&lt;BR /&gt;8,08Sep2017,30Sep2017&lt;BR /&gt;8,18Oct2017,31Oct2017&lt;BR /&gt;8,08Nov2017,30Nov2017&lt;BR /&gt;8,08Dec2017,31Dec2017&lt;BR /&gt;8,16Jan2018,31Jan2018&lt;BR /&gt;8,02Feb2018,28Feb2018&lt;BR /&gt;8,02Mar2018,31Mar2018&lt;BR /&gt;8,19Apr2018,30Apr2018&lt;BR /&gt;8,09May2018,31May2018&lt;BR /&gt;8,14Aug2018,31Aug2018&lt;BR /&gt;8,27Sep2018,30Sep2018&lt;BR /&gt;8,08Nov2018,30Nov2018&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The target data set is as below:&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input DummyID Eligible;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1&lt;BR /&gt;2,1&lt;BR /&gt;3,1&lt;BR /&gt;4,1&lt;BR /&gt;5,1&lt;BR /&gt;6,1&lt;BR /&gt;7,0&lt;BR /&gt;8,0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any insight would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 03:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848273#M335370</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2022-12-07T03:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Check eligibility based on enrollment info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848276#M335373</link>
      <description>&lt;P&gt;&lt;BR /&gt;data have2 (drop=i);&lt;BR /&gt;set have;&lt;BR /&gt;by DummyID; &lt;BR /&gt;if (first.DummyID or not last.DummyID) then&lt;BR /&gt;do i = 1 to 1 + (first.DummyID and not last.DummyID);&lt;BR /&gt;set have (keep=Enroll_beg_dt rename=(Enroll_beg_dt=nextval) );&lt;BR /&gt;end;&lt;BR /&gt;if last.DummyID then &lt;BR /&gt;nextval = .;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data have3;&lt;BR /&gt;set have2;&lt;BR /&gt;dur = Enroll_end_dt - Enroll_beg_dt + 1;&lt;BR /&gt;gap = nextval - Enroll_beg_dt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc summary data = have3 nway;&lt;BR /&gt;class DummyID;&lt;BR /&gt;output out=want (DROP = _FREQ_ _TYPE_) &lt;BR /&gt;max(gap)=maxgap&lt;BR /&gt;sum(dur)=sumdur&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 06:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848276#M335373</guid>
      <dc:creator>RD2</dc:creator>
      <dc:date>2022-12-07T06:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Check eligibility based on enrollment info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848323#M335394</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover dsd;
input DummyID (Enroll_beg_dt Enroll_end_dt) (:date9.);
format Enroll_beg_dt Enroll_end_dt date9.;
datalines;
1,01Jan2017,28Feb2018
1,02Mar2018,31Mar2018
1,02Apr2018,08Jul2018
1,01Aug2018,31Dec2018
2,01Jan2017,07Aug2017
2,03Oct2017,31May2018
2,01Oct2018,30Nov2018
3,01Jan2017,28Feb2018
3,02Mar2018,31Mar2018
3,02Apr2018,31Dec2018
4,01Jan2017,31Dec2018
5,01Oct2017,28Feb2018
6,01Jan2017,28Feb2018
6,02Mar2018,31Mar2018
6,02Apr2018,31Dec2018
7,01Apr2018,05Apr2018
7,01May2018,30Sep2018
7,01Nov2018,31Dec2018
8,01Aug2017,31Aug2017
8,08Sep2017,30Sep2017
8,18Oct2017,31Oct2017
8,08Nov2017,30Nov2017
8,08Dec2017,31Dec2017
8,16Jan2018,31Jan2018
8,02Feb2018,28Feb2018
8,02Mar2018,31Mar2018
8,19Apr2018,30Apr2018
8,09May2018,31May2018
8,14Aug2018,31Aug2018
8,27Sep2018,30Sep2018
8,08Nov2018,30Nov2018
;
run;

data temp;
 set have;
 do date=Enroll_beg_dt to Enroll_end_dt;
  output;
 end;
keep DummyID date;
format date date9.;
run;
proc sort data=temp nodupkey ;by  DummyID date;run;
data temp;
 set temp;
 by DummyID;
 if first.DummyID or dif(date)&amp;gt;60 then group+1;
run;
proc sql;
create table want as
select DummyID,max(n)&amp;gt;365 as Eligible from 
(
select DummyID,group,count(*) as n
 from temp
  group by DummyID,group
)
group by DummyID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848323#M335394</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-12-07T11:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Check eligibility based on enrollment info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848359#M335410</link>
      <description>&lt;P&gt;Thanks a lot, Ksharp!&lt;/P&gt;
&lt;P&gt;The only part that doesn't work well is for DummyID=2, where its first record has enrollment duration of 218 days, the second record has 240 days,&amp;nbsp;and the gap in between is 57 days (which is less than 60 days). This case the enrollment duration is 218+240=458, so&amp;nbsp;DummyID=2 should be eligible given that it had at least 365 days of enrollment with no more than one gap of maximum of 60 days.&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;2,01Jan2017,07Aug2017
2,03Oct2017,31May2018
2,01Oct2018,30Nov2018&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Maybe a small twist may make it work?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 15:21:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848359#M335410</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2022-12-07T15:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Check eligibility based on enrollment info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848517#M335462</link>
      <description>&lt;P&gt;I don't understand .&lt;/P&gt;
&lt;P&gt;My DummyID=2 is eligibled as you showed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1670499625311.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78190i7AFF7F5D04D26F6A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1670499625311.png" alt="Ksharp_0-1670499625311.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 11:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848517#M335462</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-12-08T11:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Check eligibility based on enrollment info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848530#M335469</link>
      <description>My bad! I used my initial data set. You got it. Thanks a lot!</description>
      <pubDate>Thu, 08 Dec 2022 13:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-eligibility-based-on-enrollment-info/m-p/848530#M335469</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2022-12-08T13:38:32Z</dc:date>
    </item>
  </channel>
</rss>

