That was crystal clear! Thanks again, @SASJedi ! I encountered another challenge. I have two time periods: (i) Sep, Oct, Nov 2018 and (ii) Dec 2018, Jan, Feb 2019. I would also like to see the numbers of unique clients newly enrolled, exited, and retained from time period (i) to (ii). I used the following sample data: data prepost;
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
; I modified the code you wrote to get the numbers but I could not get the desired result. The code is: proc sql;
create table prepost_q6 as
select id
/* Each logical expression produces a 1 if true, 0 if false */
,sum( month in (9,10,11))=0 AND year=2018 /* Not enrolled first */
AND
(sum( month in (12))>0 AND year=2018
OR
sum ( month in (1,2))>0 AND year=2019) /* Enrolled second */ as preq6_newenrol
,sum( month in (9,10,11))>0 AND year=2018 /* Enrolled first */
AND
(sum( month in (12))=0 AND year=2018
OR
sum ( month in (1,2))=0 AND year=2019) /* Not enrolled second */ as preq6_exited
,sum( month in (9,19,11))>0 /* Enrolled first */
AND
(sum( month in (12))>0 AND year=2018
OR
sum ( month in (1,2))>0 AND year=2019) /* Enrolled second */ as preq6_retained
from work.prepost
group by id
;
quit; Could you please help me in getting the code correct to have the numbers of unique clients newly enrolled, exited, and retained from time period (i) to (ii)? Thank you!
... View more