<?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 Enrollment coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677407#M204333</link>
    <description>Hello Mathias,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for your help! Yes, that will be a good start. I am applying your code by modifying it a bit according to my whole dataset. I will let you know if that works and if I come up with any other concerns.&lt;BR /&gt;&lt;BR /&gt;Thanks again!&lt;BR /&gt;Farah</description>
    <pubDate>Tue, 18 Aug 2020 06:31:03 GMT</pubDate>
    <dc:creator>ftahsin</dc:creator>
    <dc:date>2020-08-18T06:31:03Z</dc:date>
    <item>
      <title>Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/672438#M202113</link>
      <description>&lt;P&gt;Hello SAS Community,&lt;BR /&gt;&lt;BR /&gt;I am working on a Medicaid dataset that includes a treatment and a control group. To finalize who will be in my treatment group, I need to determine the patients who had continuous enrollment for at least 9 months into an intervention program. I already reconciled the dataset and removed all the duplicated months and years of their enrollment. My reconciling code worked fine, which was-&lt;BR /&gt;&lt;BR /&gt;data Babies_Clean(drop=prior_: temp_: orig_:);&lt;BR /&gt;retain orsid begin end;&lt;BR /&gt;format Prior_end Orig_begin Orig_end&lt;BR /&gt;temp_beg temp_end begin end yymm10.;&lt;BR /&gt;set Mcaid_elig_babies(rename=(begin=Orig_begin&lt;BR /&gt;end =Orig_end ));&lt;BR /&gt;by orsid Orig_begin Orig_end;&lt;BR /&gt;if Orig_begin &amp;gt; Orig_end then delete;&lt;BR /&gt;Prior_end = lag(Orig_end);&lt;BR /&gt;if first.orsid&lt;BR /&gt;then do;&lt;BR /&gt;temp_beg = Orig_begin;&lt;BR /&gt;temp_end = Orig_end;&lt;BR /&gt;Prior_end = .;&lt;BR /&gt;end;&lt;BR /&gt;else if 0 &amp;lt;= (Orig_begin - Prior_end) &amp;lt;= 1&lt;BR /&gt;then do;&lt;BR /&gt;temp_end = Orig_end;&lt;BR /&gt;end;&lt;BR /&gt;else if (Orig_begin - temp_end) &amp;gt; 1&lt;BR /&gt;then do;&lt;BR /&gt;begin = temp_beg;&lt;BR /&gt;end = temp_end;&lt;BR /&gt;output;&lt;BR /&gt;temp_beg = Orig_begin;&lt;BR /&gt;temp_end = Orig_end;&lt;BR /&gt;end;&lt;BR /&gt;else if temp_beg &amp;lt;= Orig_begin &amp;lt;= temp_end&lt;BR /&gt;then do;&lt;BR /&gt;if Orig_end &amp;gt; temp_end&lt;BR /&gt;then temp_end = Orig_end;&lt;BR /&gt;end;&lt;BR /&gt;if last.orsid then do;&lt;BR /&gt;begin = temp_beg;&lt;BR /&gt;if Orig_end &amp;gt; temp_end&lt;BR /&gt;then end = Orig_end;&lt;BR /&gt;else end = temp_end;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Now I want to write the codes that will indicate the patients who were enrolled for at least 9 months into that program separately from those who were enrolled for less than 9 months. I also want to create a new binary variable that will show this indication [i.e., 1 = eligible (had at least 9 months enrollment), 0 = not eligible).&lt;BR /&gt;&lt;BR /&gt;Please help me with this coding.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!&lt;BR /&gt;Farah&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 02:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/672438#M202113</guid>
      <dc:creator>ftahsin</dc:creator>
      <dc:date>2020-07-27T02:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/673052#M202389</link>
      <description>&lt;P&gt;Hello Farah,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is going to be difficult without a good idea of the structure of the dataset and the record layout. Could you share a couple of rows with some sample data that could help clarifying your question ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mathias.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 08:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/673052#M202389</guid>
      <dc:creator>MCoopmans</dc:creator>
      <dc:date>2020-07-29T08:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/673282#M202510</link>
      <description>&lt;P&gt;Hello Mathias,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply. I have attached a screenshot of my main 3 raws here:&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="ftahsin_1-1596049509307.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47792iADFD39601ECD1323/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ftahsin_1-1596049509307.png" alt="ftahsin_1-1596049509307.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I apologize, I have reconciled the dates and deleted the duplicates (i.e., Mar 2009 - July 2017 for the 1st orsid 8760376, instead of keeping it in 2 separate sections). But, unfortunately, my file crashed and I am working on it again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this will help with the code for continuous enrollment that I want. For example, the 1st orsid was enrolled from March 2009 - July 2017 (more than 9 months), so he is eligible for my study. Orsid 8749769 was enrolled from November 2008 - May 2009 (less than 9 months, as we can get from the table), so he won't be eligible. There are thousands of ID's in my dataset, so I can't do them manually. I need a code for that and I also want to create a variable that will indicate 1 = eligible and 0 = not, according to equal or more than 9 months and less than that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Farah&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 19:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/673282#M202510</guid>
      <dc:creator>ftahsin</dc:creator>
      <dc:date>2020-07-29T19:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677342#M204299</link>
      <description>&lt;P&gt;Hi Farah,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you still looking for a solution ? I think this example here would be a good start:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
infile cards;
input orsid begin : date9. end : date9.;
format begin end monyy7.;
cards;
8760376 01MAR2009 01JAN2010
8760376 01JAN2010 01JUL2017
8749769 01NOV2008 01APR2009
8749769 01NOV2008 01MAY2009
8749769 01NOV2008 01MAY2009
;
run;

data want;
 set have ;
 retain prev_begin prev_end;
 by notsorted orsid;
  if not first.orsid then do;
   if begin le prev_end  then begin=prev_begin;
  end;
 length=INTCK('MONTH',begin,end);
 prev_begin=begin;
 prev_end=end;
  format prev_begin prev_end monyy7.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the resulting dataset:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-08-17_220747.png" style="width: 450px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48357i5CE4BF8FDC5EFD43/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-08-17_220747.png" alt="2020-08-17_220747.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see in the second row the "begin" date was copied from the "begin" date of the first row since the 2 periods are overlapping for the same orsid. The length variable holds the number of months that are between the begin and end variable. You could add some code to only retain the maximum value of length by orsid.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this help ?&lt;/P&gt;
&lt;P&gt;Mathias.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 20:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677342#M204299</guid>
      <dc:creator>MCoopmans</dc:creator>
      <dc:date>2020-08-17T20:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677373#M204313</link>
      <description>&lt;P&gt;What do you want the output to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;One record per spell, with beginning and ending dates of each continuous spell (and maybe a new variable with length-of-spell)?&amp;nbsp; If a person has two spells, they could possibly have one of 9 months or more, and one of less-than 9 months.&lt;/LI&gt;
&lt;LI&gt;One record per id, where a person ends up in the desired file once if they have ANY spells of 9 months or more.&amp;nbsp; If so, what date information would you want, from the multiple candidate spells?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 18 Aug 2020 00:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677373#M204313</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-18T00:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677407#M204333</link>
      <description>Hello Mathias,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for your help! Yes, that will be a good start. I am applying your code by modifying it a bit according to my whole dataset. I will let you know if that works and if I come up with any other concerns.&lt;BR /&gt;&lt;BR /&gt;Thanks again!&lt;BR /&gt;Farah</description>
      <pubDate>Tue, 18 Aug 2020 06:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677407#M204333</guid>
      <dc:creator>ftahsin</dc:creator>
      <dc:date>2020-08-18T06:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous Enrollment coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677408#M204334</link>
      <description>Hello mkeintz,&lt;BR /&gt;&lt;BR /&gt;My expected output will be the 1st option that you mentioned. One record per spell, with beginning and ending dates of each continuous spell.&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Aug 2020 06:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-Enrollment-coding/m-p/677408#M204334</guid>
      <dc:creator>ftahsin</dc:creator>
      <dc:date>2020-08-18T06:35:23Z</dc:date>
    </item>
  </channel>
</rss>

