<?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 across years following a birth event in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869814#M343580</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43822"&gt;@Wolverine&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It works!&amp;nbsp; And it's a much better solution than all the IF-THEN statements I was thinking about.&amp;nbsp; Thank you!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You will often find that wide data is more difficult to work with in SAS than long.&lt;/P&gt;
&lt;P&gt;When a question relates to date, time or datetime intervals or ranges of values one of the first things to look for is getting actual date, time&amp;nbsp; or datetime values to work with rules involving the interval or duration calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach, that I am not going to code, is once you have the Useful data set is to use BY group processing based on the Id and deliv_date values, assume the flag variable is 1 until a 0 is encountered to set the flag as 0. Which would be one approach if you needed a "when was continuous broken" as well as if you needed "when enrollment restarted".&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2023 14:53:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-04-14T14:53:43Z</dc:date>
    <item>
      <title>Continuous enrollment across years following a birth event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869605#M343478</link>
      <description>&lt;P&gt;I've identified birth events in the data, and now I need to see if the mom has continuous enrollment for insurance coverage for the subsequent 12 months (so for a birth in June 2017, she would have to have continuous enrollment until May 2018).&amp;nbsp; The data looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;data test;
    input ID deliv_date YEAR_of_BIRTH YEAR_of_ENROLL ENRMON1 ENRMON2 ENRMON3 ENRMON4 ENRMON5 ENRMON6 ENRMON7 ENRMON8 ENRMON9 ENRMON10 ENRMON11 ENRMON12;
    datalines;
    1234    06/01/2017  2017   2017 1 1 1 1 1 1 1 1 1 1 1 1
    1234    06/01/2017  2017   2018 1 1 1 1 1 1 1 1 1 1 1 1
    1234    06/01/2017  2017   2019 1 1 1 1 1 1 1 1 1 1 1 1&lt;BR /&gt;    2345    08/15/2018  2018   2017 1 1 1 1 1 1 1 1 1 1 1 1
    2345    08/15/2018  2018   2018 1 1 1 1 1 1 1 1 1 1 1 1&lt;BR /&gt;    2345    08/15/2018  2018   2019 0 1 1 1 1 1 1 1 1 1 1 1
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;In this example, ID 1234 has a baby on June 1 2017 and has continuous coverage for 12+ months.&amp;nbsp; But ID 2345 does NOT have continuous coverage due to the gap in Jan 2019.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a flag for each case: contin_enroll = 1 if the case meets the criteria, or 0 if the case does not.&amp;nbsp; I have some ideas on how to do this using a bunch of IF/THEN statements, but it would be clunky and tedious to program.&amp;nbsp; I'm hoping for guidance on a better solution.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 15:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869605#M343478</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-04-13T15:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment across years following a birth event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869626#M343494</link>
      <description>&lt;P&gt;You data step fails because you do not specify an Informat for the Deliv_date that will read the date value. It is not a simple number so it requires an informat. Is your Deliv_date an actual date value, numeric with a format like MMYYDD10. assigned or is it character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just what does "ENRMON1" mean? Does a value of 1 mean that the mom was enrolled for the month of January? Or for the first month after birth?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where does the flag go? What, ideally, does the output data look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One might ask why you bother to have enrollment values for a year prior to birth to the child if the important part is "12 months after birth". No flag makes sense for any observation where the Year_of_Enroll is less than the Year_of_birth, or if the Year_of_enroll is 2 or more years after the Year_of_birth.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 17:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869626#M343494</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-13T17:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment across years following a birth event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869630#M343497</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You data step fails because you do not specify an Informat for the Deliv_date that will read the date value. It is not a simple number so it requires an informat. Is your Deliv_date an actual date value, numeric with a format like MMYYDD10. assigned or is it character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just what does "ENRMON1" mean? Does a value of 1 mean that the mom was enrolled for the month of January? Or for the first month after birth?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where does the flag go? What, ideally, does the output data look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One might ask why you bother to have enrollment values for a year prior to birth to the child if the important part is "12 months after birth". No flag makes sense for any observation where the Year_of_Enroll is less than the Year_of_birth, or if the Year_of_enroll is 2 or more years after the Year_of_birth.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;deliv_date is an actual date value, with the format MMYYDD10.&amp;nbsp; ENRMON1 indicates coverage for January in the year of enrollment.&amp;nbsp; ENRMON2 is for February, ENRMON3 for March, etc.&amp;nbsp; 1=enrollment for that month, 0=no enrollment.&lt;BR /&gt;&lt;BR /&gt;The final output file could just be a single line for each ID, with a value of 0 or 1 for the contin_enroll flag.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The enrollment flags for years prior to birth or more than 12 months after birth are simply what's in the data, and I didn't see any reason to delete them.&amp;nbsp; And it's possible, as this project develops, that we might want to see what kind of prenatal care the mother received.&amp;nbsp; In that case, we would need to know if she was enrolled during pregnancy.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 17:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869630#M343497</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-04-13T17:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment across years following a birth event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869634#M343501</link>
      <description>&lt;P&gt;One way that does what I understand:&lt;/P&gt;
&lt;PRE&gt;data test;
    input ID deliv_date:mmddyy10. YEAR_of_BIRTH YEAR_of_ENROLL ENRMON1 ENRMON2 ENRMON3 ENRMON4 ENRMON5 ENRMON6 ENRMON7 ENRMON8 ENRMON9 ENRMON10 ENRMON11 ENRMON12;
    format deliv_date mmddyy10.;
    datalines;
1234    06/01/2017  2017   2017 1 1 1 1 1 1 1 1 1 1 1 1
1234    06/01/2017  2017   2018 1 1 1 1 1 1 1 1 1 1 1 1
1234    06/01/2017  2017   2019 1 1 1 1 1 1 1 1 1 1 1 1
2345    08/15/2018  2018   2017 1 1 1 1 1 1 1 1 1 1 1 1
2345    08/15/2018  2018   2018 1 1 1 1 1 1 1 1 1 1 1 1
2345    08/15/2018  2018   2019 0 1 1 1 1 1 1 1 1 1 1 1
;

/* get dates for the enrollments and restructure*/
data useful;
   set test;
   array m (*) enrmon: ;
   do i=1 to dim(m);
      testdate= mdy(i,1,year_of_enroll);
      Enrollcode = m[i];
      output;
   end;
   format testdate mmddyy10.;
   keep id -- YEAR_of_ENROLL testdate enrollcode;
run;

data setflags;
   set useful;
   if (intck('month',deliv_date,testdate) le 12) then Cont_flag = enrollcode;
run;

proc summary data=setflags nway;
   class id  deliv_date YEAR_of_BIRTH;
   var  Cont_flag;
   output out=want (drop=_: ) min= ;
run;&lt;/PRE&gt;
&lt;P&gt;The Useful set could be used with different logic to look at other insured dates.&lt;/P&gt;
&lt;P&gt;The Setflags could be done with one step but since the Useful set might be wanted as a start for something else I think it may be worth having.&lt;/P&gt;
&lt;P&gt;Summary, with the Cont_flags conditionally set only&amp;nbsp; for the period following birth, then lets you get the minimum value. If all enrolled the flag is 1.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 18:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869634#M343501</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-13T18:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment across years following a birth event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869797#M343573</link>
      <description>&lt;P&gt;It works!&amp;nbsp; And it's a much better solution than all the IF-THEN statements I was thinking about.&amp;nbsp; Thank you!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 14:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869797#M343573</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-04-14T14:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment across years following a birth event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869814#M343580</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43822"&gt;@Wolverine&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It works!&amp;nbsp; And it's a much better solution than all the IF-THEN statements I was thinking about.&amp;nbsp; Thank you!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You will often find that wide data is more difficult to work with in SAS than long.&lt;/P&gt;
&lt;P&gt;When a question relates to date, time or datetime intervals or ranges of values one of the first things to look for is getting actual date, time&amp;nbsp; or datetime values to work with rules involving the interval or duration calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach, that I am not going to code, is once you have the Useful data set is to use BY group processing based on the Id and deliv_date values, assume the flag variable is 1 until a 0 is encountered to set the flag as 0. Which would be one approach if you needed a "when was continuous broken" as well as if you needed "when enrollment restarted".&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 14:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-across-years-following-a-birth-event/m-p/869814#M343580</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-14T14:53:43Z</dc:date>
    </item>
  </channel>
</rss>

