<?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 Continuous enrollment each year for 5 years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678689#M204871</link>
    <description>&lt;P&gt;Hello SAS programmers,&lt;/P&gt;&lt;P&gt;I have the following data. Looking to count forward 12 months from birthdt (anchor date). If baby is enrolled 9 of 12 months in that first year of life, then ceyr1flag=1 (else flag is 0). Count forward another 12 months (this is year 2 of life now). If baby enrolled 9 of 12 months, then ceyr2flag=1 (else 0). While I only provide 2 years of data below to keep this post a reasonable length, I'm looking to do this through the first 5 years of life. Would have 5 flags (i.e. ceyr1flag--ceyr5flag).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me with some code? Thank you very much! If you would like 5 years of data for each ID, I'm happy to provide.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID birthdt MONYY7. year month $ enrolled;
format birthdt MONYY7.;
datalines;
6816494	Feb2006	2006	Feb	1
6816494	Feb2006	2006	Mar	1
6816494	Feb2006	2006	Apr	1
6816494	Feb2006	2006	May	1
6816494	Feb2006	2006	Jun	0
6816494	Feb2006	2006	Jul	0
6816494	Feb2006	2006	Aug	0
6816494	Feb2006	2006	Sep	0
6816494	Feb2006	2006	Oct	0
6816494	Feb2006	2006	Nov	0
6816494	Feb2006	2006	Dec	0
6816494	Feb2006	2007	Jan	0
6816494	Feb2006	2007	Feb	0
6816494	Feb2006	2007	Mar	0
6816494	Feb2006	2007	Apr	0
6816494	Feb2006	2007	May	0
6816494	Feb2006	2007	Jun	0
6816494	Feb2006	2007	Jul	0
6816494	Feb2006	2007	Aug	0
6816494	Feb2006	2007	Sep	0
6816494	Feb2006	2007	Oct	0
6816494	Feb2006	2007	Nov	0
6816494	Feb2006	2007	Dec	0
6816494	Feb2006	2008	Jan	0
7298021	Aug2006	2006	Aug	1
7298021	Aug2006	2006	Sep	1
7298021	Aug2006	2006	Oct	1
7298021	Aug2006	2006	Nov	1
7298021	Aug2006	2006	Dec	1
7298021	Aug2006	2007	Jan	1
7298021	Aug2006	2007	Feb	1
7298021	Aug2006	2007	Mar	1
7298021	Aug2006	2007	Apr	1
7298021	Aug2006	2007	May	1
7298021	Aug2006	2007	Jun	1
7298021	Aug2006	2007	Jul	1
7298021	Aug2006	2007	Aug	1
7298021	Aug2006	2007	Sep	1
7298021	Aug2006	2007	Oct	1
7298021	Aug2006	2007	Nov	1
7298021	Aug2006	2007	Dec	1
7298021	Aug2006	2008	Jan	1
7298021	Aug2006	2008	Feb	1
7298021	Aug2006	2008	Mar	1
7298021	Aug2006	2008	Apr	1
7298021	Aug2006	2008	May	1
7298021	Aug2006	2008	Jun	1
7298021	Aug2006	2008	Jul	1
7358913	Nov2006	2006	Nov	1
7358913	Nov2006	2006	Dec	1
7358913	Nov2006	2007	Jan	1
7358913	Nov2006	2007	Feb	1
7358913	Nov2006	2007	Mar	1
7358913	Nov2006	2007	Apr	1
7358913	Nov2006	2007	May	1
7358913	Nov2006	2007	Jun	1
7358913	Nov2006	2007	Jul	1
7358913	Nov2006	2007	Aug	1
7358913	Nov2006	2007	Sep	1
7358913	Nov2006	2007	Oct	1
7358913	Nov2006	2007	Nov	1
7358913	Nov2006	2007	Dec	1
7358913	Nov2006	2008	Jan	1
7358913	Nov2006	2008	Feb	1
7358913	Nov2006	2008	Mar	1
7358913	Nov2006	2008	Apr	0
7358913	Nov2006	2008	May	0
7358913	Nov2006	2008	Jun	0
7358913	Nov2006	2008	Jul	0
7358913	Nov2006	2008	Aug	0
7358913	Nov2006	2008	Sep	0
7358913	Nov2006	2008	Oct	0
7487475	Dec2012	2012	Dec	1
7487475	Dec2012	2013	Jan	1
7487475	Dec2012	2013	Feb	1
7487475	Dec2012	2013	Mar	1
7487475	Dec2012	2013	Apr	1
7487475	Dec2012	2013	May	1
7487475	Dec2012	2013	Jun	1
7487475	Dec2012	2013	Jul	1
7487475	Dec2012	2013	Aug	0
7487475	Dec2012	2013	Sep	0
7487475	Dec2012	2013	Oct	0
7487475	Dec2012	2013	Nov	0
7487475	Dec2012	2013	Dec	0
7487475	Dec2012	2014	Jan	0
7487475	Dec2012	2014	Feb	0
7487475	Dec2012	2014	Mar	1
7487475	Dec2012	2014	Apr	1
7487475	Dec2012	2014	May	1
7487475	Dec2012	2014	Jun	1
7487475	Dec2012	2014	Jul	1
7487475	Dec2012	2014	Aug	1
7487475	Dec2012	2014	Sep	1
7487475	Dec2012	2014	Oct	1
7487475	Dec2012	2014	Nov	1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 22 Aug 2020 18:47:31 GMT</pubDate>
    <dc:creator>eabc0351</dc:creator>
    <dc:date>2020-08-22T18:47:31Z</dc:date>
    <item>
      <title>Continuous enrollment each year for 5 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678689#M204871</link>
      <description>&lt;P&gt;Hello SAS programmers,&lt;/P&gt;&lt;P&gt;I have the following data. Looking to count forward 12 months from birthdt (anchor date). If baby is enrolled 9 of 12 months in that first year of life, then ceyr1flag=1 (else flag is 0). Count forward another 12 months (this is year 2 of life now). If baby enrolled 9 of 12 months, then ceyr2flag=1 (else 0). While I only provide 2 years of data below to keep this post a reasonable length, I'm looking to do this through the first 5 years of life. Would have 5 flags (i.e. ceyr1flag--ceyr5flag).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me with some code? Thank you very much! If you would like 5 years of data for each ID, I'm happy to provide.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID birthdt MONYY7. year month $ enrolled;
format birthdt MONYY7.;
datalines;
6816494	Feb2006	2006	Feb	1
6816494	Feb2006	2006	Mar	1
6816494	Feb2006	2006	Apr	1
6816494	Feb2006	2006	May	1
6816494	Feb2006	2006	Jun	0
6816494	Feb2006	2006	Jul	0
6816494	Feb2006	2006	Aug	0
6816494	Feb2006	2006	Sep	0
6816494	Feb2006	2006	Oct	0
6816494	Feb2006	2006	Nov	0
6816494	Feb2006	2006	Dec	0
6816494	Feb2006	2007	Jan	0
6816494	Feb2006	2007	Feb	0
6816494	Feb2006	2007	Mar	0
6816494	Feb2006	2007	Apr	0
6816494	Feb2006	2007	May	0
6816494	Feb2006	2007	Jun	0
6816494	Feb2006	2007	Jul	0
6816494	Feb2006	2007	Aug	0
6816494	Feb2006	2007	Sep	0
6816494	Feb2006	2007	Oct	0
6816494	Feb2006	2007	Nov	0
6816494	Feb2006	2007	Dec	0
6816494	Feb2006	2008	Jan	0
7298021	Aug2006	2006	Aug	1
7298021	Aug2006	2006	Sep	1
7298021	Aug2006	2006	Oct	1
7298021	Aug2006	2006	Nov	1
7298021	Aug2006	2006	Dec	1
7298021	Aug2006	2007	Jan	1
7298021	Aug2006	2007	Feb	1
7298021	Aug2006	2007	Mar	1
7298021	Aug2006	2007	Apr	1
7298021	Aug2006	2007	May	1
7298021	Aug2006	2007	Jun	1
7298021	Aug2006	2007	Jul	1
7298021	Aug2006	2007	Aug	1
7298021	Aug2006	2007	Sep	1
7298021	Aug2006	2007	Oct	1
7298021	Aug2006	2007	Nov	1
7298021	Aug2006	2007	Dec	1
7298021	Aug2006	2008	Jan	1
7298021	Aug2006	2008	Feb	1
7298021	Aug2006	2008	Mar	1
7298021	Aug2006	2008	Apr	1
7298021	Aug2006	2008	May	1
7298021	Aug2006	2008	Jun	1
7298021	Aug2006	2008	Jul	1
7358913	Nov2006	2006	Nov	1
7358913	Nov2006	2006	Dec	1
7358913	Nov2006	2007	Jan	1
7358913	Nov2006	2007	Feb	1
7358913	Nov2006	2007	Mar	1
7358913	Nov2006	2007	Apr	1
7358913	Nov2006	2007	May	1
7358913	Nov2006	2007	Jun	1
7358913	Nov2006	2007	Jul	1
7358913	Nov2006	2007	Aug	1
7358913	Nov2006	2007	Sep	1
7358913	Nov2006	2007	Oct	1
7358913	Nov2006	2007	Nov	1
7358913	Nov2006	2007	Dec	1
7358913	Nov2006	2008	Jan	1
7358913	Nov2006	2008	Feb	1
7358913	Nov2006	2008	Mar	1
7358913	Nov2006	2008	Apr	0
7358913	Nov2006	2008	May	0
7358913	Nov2006	2008	Jun	0
7358913	Nov2006	2008	Jul	0
7358913	Nov2006	2008	Aug	0
7358913	Nov2006	2008	Sep	0
7358913	Nov2006	2008	Oct	0
7487475	Dec2012	2012	Dec	1
7487475	Dec2012	2013	Jan	1
7487475	Dec2012	2013	Feb	1
7487475	Dec2012	2013	Mar	1
7487475	Dec2012	2013	Apr	1
7487475	Dec2012	2013	May	1
7487475	Dec2012	2013	Jun	1
7487475	Dec2012	2013	Jul	1
7487475	Dec2012	2013	Aug	0
7487475	Dec2012	2013	Sep	0
7487475	Dec2012	2013	Oct	0
7487475	Dec2012	2013	Nov	0
7487475	Dec2012	2013	Dec	0
7487475	Dec2012	2014	Jan	0
7487475	Dec2012	2014	Feb	0
7487475	Dec2012	2014	Mar	1
7487475	Dec2012	2014	Apr	1
7487475	Dec2012	2014	May	1
7487475	Dec2012	2014	Jun	1
7487475	Dec2012	2014	Jul	1
7487475	Dec2012	2014	Aug	1
7487475	Dec2012	2014	Sep	1
7487475	Dec2012	2014	Oct	1
7487475	Dec2012	2014	Nov	1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Aug 2020 18:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678689#M204871</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2020-08-22T18:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment each year for 5 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678708#M204886</link>
      <description>&lt;P&gt;You would make your life easier if your months were numbers 1 through 12 rather than character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 1 — compute year of life&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID birthdt MONYY7. year month $ enrolled;
currmonth=input(cats('01',month,year),date9.);
year_of_life=intck('year',birthdt,currmonth,'c');
format birthdt monyy7.;
datalines; /* I have left the data out here, just because it is long and no need to repeat it */
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Step 2 — add up all the 1s and 0s under enrollment for each year of life&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class id year_of_life;
    var enrolled;
    output out=sums sum=sum_enrolled;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 3 — if the sum of the enrolled is 9 or more, you get the year flag=1, else 0 — I leave this up to you as a homework assignment. I will say that I strongly recommend that you leave the data in the long form as outputted from PROC SUMMARY, with one more variable if the sum of enrolled is 9 or more; rather than creating 5 new variables ceyr1flag,ceyr2flag, &lt;EM&gt;etc&lt;/EM&gt;. which is a lot more programming to create, and a lot more programming to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 22:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678708#M204886</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-22T22:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment each year for 5 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678756#M204918</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;. Happy your bitmoji is staying safe during covid times.</description>
      <pubDate>Sun, 23 Aug 2020 16:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-each-year-for-5-years/m-p/678756#M204918</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2020-08-23T16:15:27Z</dc:date>
    </item>
  </channel>
</rss>

