<?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 to set up continuous enrollment for medicare data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/873515#M345140</link>
    <description>&lt;P&gt;Hi Ksharp, I have a follow-up question on your code. When a person have a break in their enrollment, for example, I revised the original dataset to the following and please note that person a now was enrolled from July 2019 to June 2020, had a break in July 2020, but then was re-enrolled in August 2020 then all the way to December 2020.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 &lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt; 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this case, the desired output would be as follow. My question is how do you revise the code that you provided to accommodate such situation? Thank you for your help!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;
id &amp;nbsp;&amp;nbsp;&amp;nbsp;start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end
a&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;July2019 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Jun2020&lt;BR /&gt;a      Aug2020      Dec2020
b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Jan2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Oct2020
c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb2017&amp;nbsp;&amp;nbsp;&amp;nbsp; May2020.&amp;nbsp;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 02:50:19 GMT</pubDate>
    <dc:creator>roroholic123</dc:creator>
    <dc:date>2023-05-03T02:50:19Z</dc:date>
    <item>
      <title>how to set up continuous enrollment for medicare data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824213#M325466</link>
      <description>&lt;P&gt;Hi SAS Experts,&lt;/P&gt;&lt;P&gt;Sorry to bother but really need a hand. I was working on the enrollment of&amp;nbsp; Medicare beneficiaries.&lt;/P&gt;&lt;P&gt;However, I really got stuck.&amp;nbsp;&amp;nbsp;My quick question is how to set up start date and end date for enrollment status by id like below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 1 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How can I transfer the data to below?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;
id &amp;nbsp;&amp;nbsp;&amp;nbsp;start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end
a&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;July2019 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dec2020
b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Jan2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Oct2020
c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb2017&amp;nbsp;&amp;nbsp;&amp;nbsp; May2020&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you so much for the advice!!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824213#M325466</guid>
      <dc:creator>chimei0403</dc:creator>
      <dc:date>2022-07-19T18:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to set up continuous enrollment for medicare data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824222#M325474</link>
      <description>&lt;P&gt;One thing is to avoid "wide" data sets and to use actual date values.&lt;/P&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 1 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
run;

/* make a LONG set with an actual date*/

data need;
   set enrollment;
   array m (*) Jan Feb March April May June July August Sep Oct Nov Dec;
   do i=1 to dim(m);
      if m[i] then do;
         date =mdy(i,1,year);
         output;
      end;
   end;
   keep id date;
   format date date9.;
run;

/*report*/
proc tabulate data=need;
   class id;
   var date;
   table id,
         date=''*(min='Start'*f=monyy7. max='End'*f=monyy7.);
run;
/*data set*/
proc summary data=need nway;
   class id;
   var date;
   output out=want (drop=_:) min=Start max=end;
run;

proc print data=want;
  format start end monyy7.;
run;
&lt;/PRE&gt;
&lt;P&gt;Date values, such as created by the MDY function (or others) allows use of formats to display dates in a nice fashion. Also there are functions to work with the date values to determine intervals and such.&lt;/P&gt;
&lt;P&gt;The Long data set of one record per person per date allows summary statistics to be built easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824222#M325474</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-19T18:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to set up continuous enrollment for medicare data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824264#M325504</link>
      <description>&lt;P&gt;If &lt;EM&gt;&lt;STRONG&gt;START&lt;/STRONG&gt;&lt;/EM&gt; is always considered to be the first of the month and &lt;EM&gt;&lt;STRONG&gt;END&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;is always end of the month, then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 1 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
run;

data want (drop=_:);
  do until (last.id);
    set enrollment;
    by id;
    array dummies {12} jan -- dec;
    if start=. then start=mdy(whichn(1,of dummies{*}),1,year);
    _nmonths=sum(_nmonths,of dummies{*});
  end;
  end=intnx('month',start,_nmonths)-1;
  format start end date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program assumes there is only one sequences of 1's, with no internal 0's.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 00:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824264#M325504</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-07-20T00:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to set up continuous enrollment for medicare data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824332#M325540</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 1 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
;
run;
data temp;
 set enrollment;
 call scan(cats(of Jan--Dec),1,p,l,'0');
 start=mdy(p,1,year);
 end=mdy(p+l-1,1,year);
format start end monyy7.;
run;
proc summary data=temp nway;
class id;
var start end;
output out=want min(start)=start max(end)=end ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2022 12:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/824332#M325540</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-20T12:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to set up continuous enrollment for medicare data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/873515#M345140</link>
      <description>&lt;P&gt;Hi Ksharp, I have a follow-up question on your code. When a person have a break in their enrollment, for example, I revised the original dataset to the following and please note that person a now was enrolled from July 2019 to June 2020, had a break in July 2020, but then was re-enrolled in August 2020 then all the way to December 2020.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 &lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt; 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this case, the desired output would be as follow. My question is how do you revise the code that you provided to accommodate such situation? Thank you for your help!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;
id &amp;nbsp;&amp;nbsp;&amp;nbsp;start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end
a&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;July2019 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Jun2020&lt;BR /&gt;a      Aug2020      Dec2020
b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Jan2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Oct2020
c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb2017&amp;nbsp;&amp;nbsp;&amp;nbsp; May2020.&amp;nbsp;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 02:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/873515#M345140</guid>
      <dc:creator>roroholic123</dc:creator>
      <dc:date>2023-05-03T02:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to set up continuous enrollment for medicare data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/873597#M345181</link>
      <description>&lt;P&gt;It would be better if you could start a brand-new session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data enrollment;
input ID$ Year Jan Feb March April May June July August Sep Oct Nov Dec ;
cards;
a    2019   0  0  0 0 0 0 1 1 1 1 1 1  
a    2020   1  1  1 1 1 1 0 1 1 1 1 1 
b    2018   1  1  1 1 1 1 1 1 1 1 1 1
b    2019   1  1  1 1 1 1 1 1 1 1 1 1
b    2020   1  1  1 1 1 1 1 1 1 1 0 0   
c    2017   0  1  1 1 1 1 1 1 1 1 1 1 
c    2018   1  1  1 1 1 1 1 1 1 1 1 1 
c    2019   1  1  1 1 1 1 1 1 1 1 1 1  
c    2020   1  1  1 1 1 0 0 0 0 0 0 0  
;
run;
proc transpose data=enrollment out=temp;
by id year;
var jan--dec;
run;
data temp2;
 set temp;
 by id col1 notsorted;
 if first.col1 then group+1;
 monyy=input(cats('01',substr(_name_,1,3),year),date9.);
 format monyy monyy7.;
run;
proc summary data=temp2(where=(col1=1)) ;
by group id ;
var monyy;
output out=want min=min max=max;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2023 11:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-set-up-continuous-enrollment-for-medicare-data/m-p/873597#M345181</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-05-03T11:50:29Z</dc:date>
    </item>
  </channel>
</rss>

