<?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: Clients retained, clients exited, and new clients added in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857160#M338669</link>
    <description>&lt;P&gt;Merging done.&lt;/P&gt;</description>
    <pubDate>Sat, 04 Feb 2023 12:10:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-02-04T12:10:08Z</dc:date>
    <item>
      <title>New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856708#M338492</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello All, &amp;nbsp; I am working on a dataset that has year and month of enrollment of clients into a program (from March 2018 to February 2022). The dataset does not have information on when the clients exited the program. I have been trying to figure out: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. the number of clients newly enrolled from one year to the next (for e.g., present in 2019 but not in 2018) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. the number of clients who exited the program in the next year (for e.g., present in 2018 but not in in 2019) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. number of clients retained (for e.g., present in both 2018 and 2019). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would appreciate any help! Thanks! &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The data looks like:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data enrollment;
input id$ year month;
datalines;
1 2018 10
1 2018 11
1 2018 12
1 2019 1
1 2019 2
2 2019 10
2 2019 11
2 2019 12
3 2018 3
3 2018 4
3 2018 5
3 2019 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 18:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856708#M338492</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-01T18:44:30Z</dc:date>
    </item>
    <item>
      <title>Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856683#M338664</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a dataset that has year and month of enrollment of clients into a program (from March 2018 to February 2022). The dataset does not have information on when the clients exited the program. I have been trying to figure out:&lt;/P&gt;&lt;P&gt;1. the number of clients newly enrolled from one year to the next (for e.g., present in 2019 but not in 2018)&lt;/P&gt;&lt;P&gt;2. the number of clients who exited the program in the next year (for e.g., present in 2018 but not in in 2019)&lt;/P&gt;&lt;P&gt;3. number of clients retained (for e.g., present in both 2018 and 2019).&lt;/P&gt;&lt;P&gt;I would appreciate any help!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;The data looks like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data enrollment;
input id$ year month;
datalines;
1 2018 10
1 2018 11
1 2018 12
1 2019 1
1 2019 2
2 2019 10
2 2019 11
2 2019 12
3 2018 3
3 2018 4
3 2018 5
3 2019 1
;
run;&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 16:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856683#M338664</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-01T16:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856713#M338493</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439052"&gt;@SAS_SB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. the number of clients newly enrolled from one year to the next (for e.g., present in 2019 but not in 2018) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. the number of clients who exited the program in the next year (for e.g., present in 2018 but not in in 2019) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. number of clients retained (for e.g., present in both 2018 and 2019). &lt;/SPAN&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So based on your description, month is irrelevant?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this data representative of the&amp;nbsp;&lt;EM&gt;real &lt;/EM&gt;problem? In other words, the only two years we are discussing is 2018 and 2019, and so the only code we have to write is to check these two years? Or does the&amp;nbsp;&lt;EM&gt;real&lt;/EM&gt; problem contain more than two years? (If the latter, provide data that spans more than two years)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 19:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856713#M338493</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-01T19:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856750#M338508</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;Months could be useful if we want to have a different/specific time period. For e.g., March 2018 to Feb 2019, March 2019 to Feb 2020, etc. In addition, clients might not be in the program for all months of the year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example provided was just a truncated dataset. I have other years as well. Please find the revised example dataset as follows. Please let me know if this example is sufficient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that I have put dots (.) to indicate continuation of the months enrolled within the given year not the missing values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.enrollment;
input id$ year month;
datalines;
1 2018 10
1 2018 11
1 2018 12
1 2019 1
1 2019 2
2 2019 10
2 2019 11
2 2019 12
3 2018 3
3 2018 4
3 2018 5
3 2019 1
3 2019 12
3 2020 1
3 2020 2
4 2018 9
4 2018 10
4 2018 11
4 2018 12
4 2019 1
4 2019 2
5 2018 12
5 2019 1
5 2019 2
. .... .
5 2019 12
5 2020 1
6 2019 1
. .... .
6 2019 12
6 2020 1
. .... .
6 2020 12
6 2021 1
. .... .
6 2021 12
6 2022 1
6 2022 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 21:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856750#M338508</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-01T21:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856754#M338509</link>
      <description>&lt;P&gt;So continuing on ... I'm still not sure I understand what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a client is enrolled in January, 2018 but not the rest of the year, and is enrolled in December, 2019 but not the rest of the year ... how is that treated. Is it new enrollment, is it disenrollment, is it retention?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I don't like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Months could be useful...&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either we are supposed to be using months in the logic and code, or we are not.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 21:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856754#M338509</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-01T21:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856758#M338512</link>
      <description>&lt;P&gt;Sorry for being unclear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I would like to have the number of individuals with new enrollment, retention, and disenrollment for the periods: from period 1 (March 2018 to Feb 2019) to period 2 (March 2019 to Feb 2020) and from period 2 to period 3 (March 2020 to Feb 2021). So, how many were retained in period 2 from period 1? How many were disenrolled when moving from period 1 to period 2? etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"If a client is enrolled in January, 2018 but not the rest of the year, and is enrolled in December, 2019 but not the rest of the year ... how is that treated. Is it new enrollment, is it disenrollment, is it retention?"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For my case it would be retention.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Yes we will use months in the code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks, again!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 22:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856758#M338512</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-01T22:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856815#M338532</link>
      <description>&lt;P&gt;I think I understand now, but again I ask for a more representative data set. In particular, I cannot work with data that has dots in it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;5 2020 1
6 2019 1
. .... .
6 2019 12
6 2020 1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now, there are still only two time periods represented in the part of the data I can use, IDs 1 through 4, those two time periods being&amp;nbsp;&lt;SPAN&gt;March 2018 to Feb 2019 and&amp;nbsp;March 2019 to Feb 2020.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 11:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856815#M338532</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-02T11:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856867#M338665</link>
      <description>&lt;P&gt;With SQL, a little boolean logic can create numeric flags for each ID:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select ID
	   , SUM(year=2018)=0 and SUM(year=2019)&amp;gt;0 as NewEnrollment
	   , SUM(year=2018)&amp;gt;0 and SUM(year=2019)=0 as Exited
       , SUM(year=2018)&amp;gt;0 and SUM(year=2019)&amp;gt;0 as Retained&lt;BR /&gt;	from enrollment
	group by ID
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Producing a report like this:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;id&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;NewEnrollment&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Exited&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Retained&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Which can be used as an inline view to get the overall report:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select sum(NewEnrollment) as TotalNew
	   ,sum(Exited) as TotalExited
	   ,sum(Retained) as TotalRetained
	   from (select ID
					, SUM(year=2018)=0 and SUM(year=2019)&amp;gt;0 as NewEnrollment
					, SUM(year=2018)&amp;gt;0 and SUM(year=2019)=0 as Exited
					, SUM(year=2018)&amp;gt;0 and SUM(year=2019)&amp;gt;0 as Retained
					from enrollment
					group by ID)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and, violá!&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;TotalNew&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;TotalExited&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;TotalRetained&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856867#M338665</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-02-02T15:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856868#M338666</link>
      <description>&lt;P&gt;Normally, it is frowned upon to post the same question more than once. Can someone please merge this with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439052"&gt;@SAS_SB&lt;/a&gt;&amp;nbsp;other thread on this matter?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/856868#M338666</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-02T15:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857062#M338605</link>
      <description>&lt;P&gt;Here is the revised dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.enrollment;
input id$ year month;
datalines;
1 2018 10
1 2018 11
1 2018 12
1 2019 1
1 2019 2
2 2019 10
2 2019 11
2 2019 12
3 2018 3
3 2018 4
3 2018 5
3 2019 1
3 2019 12
3 2020 1
3 2020 2
4 2018 9
4 2018 10
4 2018 11
4 2018 12
4 2019 1
4 2019 2
5 2018 12
5 2019 1
5 2019 2
5 2019 3
5 2019 4
5 2019 5
5 2019 6
5 2019 7
5 2019 8
5 2019 9
5 2019 10
5 2019 11
5 2019 12
5 2020 1
5 2020 2
6 2019 1
6 2019 2
6 2019 3
6 2019 4
6 2019 5
6 2019 6
6 2019 7
6 2019 8
6 2019 9
6 2019 10
6 2019 11
6 2019 12
6 2020 1
6 2020 2
6 2020 3
6 2020 4
6 2020 5
6 2020 6
6 2020 7
6 2020 8
6 2020 9
6 2020 10
6 2020 11
6 2020 12
6 2021 1
6 2021 2
6 2021 3
6 2021 4
6 2021 5
6 2021 6
6 2021 7
6 2021 8
6 2021 19
6 2021 10
6 2021 11
6 2021 12
6 2022 1
6 2022 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Feb 2023 15:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857062#M338605</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-03T15:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857073#M338609</link>
      <description>&lt;P&gt;Thanks. This is what I have, it works for this data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data enrollment1;
    set enrollment;
    yymm=mdy(month,1,year);
    last_month_of_time_period=intnx('year.3',yymm,0,'e');
    year_of_enrollment=year(last_month_of_time_period)-1;
    enrolled=1;
    format yymm last_month_of_time_period yymmn6.;
run;
data enrollment2;
    set enrollment1;
    by id year_of_enrollment;
    if last.year_of_enrollment;
run;
proc transpose data=enrollment2 out=enrollment3 prefix=yr_;
    by id;
    var enrolled; 
    id year_of_enrollment;
run;

data want;
    set enrollment3(drop=_name_);
    array yr yr_2018-yr_2020;
    array new newenrollment_2018-newenrollment_2020;
    array dis disenrollment_2018-disenrollment_2020;
    array ret retention_2018-retention_2020;
    do i=1 to dim(yr);
        ret(i)=0;
        dis(i)=0;
        new(i)=0;
        if i=1 and yr(i)=1 then new(i)=1;
        if i&amp;gt;1 then do;
            if yr(i)=1 and yr(i-1)=. then new(i)=1;
            else if yr(i)=. and yr(i-1)=1 then dis(i)=1;
            else if yr(i)=1 and yr(i-1)=1 then ret(i)=1;
        end;
    end;
    drop i;
run;
proc summary data=want;
    var new: dis: ret:;
    output out=percents mean=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Feb 2023 15:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857073#M338609</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-03T15:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857095#M338667</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the time period including the months. So, I am having two time periods: (i) March to May 2018 and (ii) June to August 2018 and trying to find if the clients were newly enrolled from (i) to (ii), exited from (i) to (ii), and retained in (ii). I would be grateful if you could review the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a beginner with SAS, so apologies on silly questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
create table prepost_q1 as
select id
	   , SUM(year=2018 and (month=3 or month=5))=0 and SUM(year=2018 and (month=6 or month=8))&amp;gt;0 as preq2_newenrol
	   , SUM(year=2018 and (month=3 or month=5))&amp;gt;0 and SUM(year=2018 and (month=6 or month=8))=0 as preq2_exited
       , SUM(year=2018 and (month=3 or month=5))&amp;gt;0 and SUM(year=2019 and (month=6 or month=8))&amp;gt;0 as preq2_retained	
	from work.prepost
	group by id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Feb 2023 19:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857095#M338667</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-03T19:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857099#M338668</link>
      <description>&lt;P&gt;I tried to merge with another thread, but was unable to do so. Is there a way we can merge threads? If you have any idea, please share. It would be helpful. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 19:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857099#M338668</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-03T19:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857101#M338624</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a beginner learning SAS. So, it will take some time for me to understand the code. I am learning the different SAS statements and options. Meanwhile, if there is any simpler (for learners like me!), it would be super helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 19:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857101#M338624</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-03T19:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857104#M338626</link>
      <description>&lt;P&gt;There may be simpler ways, but I have written it relatively step by step, which might make it easier to understand.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The first data set named ENROLLMENT1 computes the last month of the time period (which I think is always Feb) and then finds the corresponding year (so Feb 2019 is really part of the 2018 year)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second data set named ENROLLMENT2 winnows the data set down to just one record per time period&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The third data set ENROLLMENT3 is transpose of ENROLLMENT2, you should look at it to see what I have done. Now that the data is in this form, a series of IF statement in WANT computes wherther or not the record was new enrollment, disenrollment or retention for each year. And then finally PROC SUMMARY computes to percent of each, by year.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 20:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857104#M338626</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-03T20:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857109#M338630</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;. The explanation is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One quick question, what would be the codes if the end month is other than February? I would like to have several quarters as time periods. For example, March to May 2018 as quarter 1 (q1), June to August 2018 as q2, September to November 2018 as q3, and so on. What is the number of unique clients newly enrolled, exited, and retained from q1 to q2, q2 to q3, and so on?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, again!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 20:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857109#M338630</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-03T20:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857113#M338634</link>
      <description>&lt;P&gt;This would require somewhat of a re-write of the code, and I don't have the time right now to do this.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 20:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857113#M338634</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-03T20:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: New enrollment, retention, and disenrollment of clients</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857114#M338635</link>
      <description>&lt;P&gt;No worries! When you get time, please write down the code. I will be keeping an eye for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 20:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857114#M338635</guid>
      <dc:creator>SAS_SB</dc:creator>
      <dc:date>2023-02-03T20:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857160#M338669</link>
      <description>&lt;P&gt;Merging done.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 12:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857160#M338669</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-04T12:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Clients retained, clients exited, and new clients added</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857360#M338791</link>
      <description>&lt;P&gt;As the question evolved here, the name of your input data set keeps changing as do the input data set vales. It makes it hard to refined the answer from previous work. So I'm going to provide both sample data and commented code here to help you apply this to your actual data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code creates the input data set:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data prepost;
input id$ year month;
datalines;
1 2018 2
1 2018 3
1 2018 4
1 2019 2
1 2019 3
1 2019 4
2 2018 8
2 2018 9
2 2018 10
3 2018 3
3 2018 4
3 2018 5
3 2018 8
3 2018 9
3 2018 10
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Which looks like this:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;id&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;year&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;month&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2019&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2019&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2019&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;This code does the summarization:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table prepost_q1 as
select id
		  /* Each logical expression produces a 1 if true, 0 if false */
	   ,sum( month in (3,5))=0 /* Not enrolled first */ 
		 AND 
		 sum( month in (6,8))&amp;gt;0 /* Enrolled second */ as preq2_newenrol

	   ,sum( month in (3,5))&amp;gt;0 /* Enrolled first */ 
		 AND 
		 sum( month in (6,8))=0 /* Not enrolled second */ as preq2_exited

	   ,sum( month in (3,5))&amp;gt;0 /* Enrolled first */ 
		 AND 
		 sum( month in (6,8))&amp;gt;0 /* Enrolled second */ as preq2_retained
	from work.prepost
	where year=2018
	group by id
;
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Producing this result:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;id&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;preq2_newenrol&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;preq2_exited&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;preq2_retained&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 06 Feb 2023 13:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-enrollment-retention-and-disenrollment-of-clients/m-p/857360#M338791</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-02-06T13:46:22Z</dc:date>
    </item>
  </channel>
</rss>

