Thanks, ballardw, all good points. Here, negative=no growth= 0 (dichotomous version in updated coded below) and positive = growth = 1. You are correct, the number of observations are not the same for each ID and this is how the real data is as well. Also correct, when I say 'initially' this can refer to 1 or more cultures where the subject is at first negative and then cultures positive or vice versa. As an end point, I think I am envisioning something along the lines of a wide dataset. Below, culture_convert is defined as any subject with at least one positive and all subsequent cultures (1 or more) are negative. ID all_positive all_negative atleast1positive consecutive_pos atleast1negative consecutive_neg culture_convert 1 0 1 0 0 1 1 0 2 0 0 1 1 1 0 0 3 0 0 1 0 1 1 1 4 0 0 1 1 1 1 1 5 0 0 1 1 1 1 1 6 0 0 1 1 1 1 0 7 0 0 1 1 1 1 1 8 1 0 1 1 0 0 0 data WORK.WANT;
infile datalines dsd truncover;
input ID:BEST. cx_date:MMDDYY10. cx_growth:BEST.;
format ID BEST. cx_date MMDDYY10. cx_growth BEST.;
label ID="ID" cx_date="cx_date" cx_growth="cx_growth";
datalines;
1 02/13/2009 0
1 05/20/2010 0
1 07/03/2012 0
1 04/18/2016 0
1 09/10/2016 0
2 01/13/2010 0
2 04/17/2012 1
2 07/16/2014 1
2 11/08/2015 1
3 05/15/2015 0
3 08/20/2018 1
3 03/01/2019 0
3 01/01/2020 0
4 03/17/2013 0
4 05/01/2015 1
4 01/15/2016 1
4 08/14/2019 0
4 10/13/2020 0
4 12/19/2020 0
4 02/04/2021 1
4 06/30/2021 0
4 10/31/2022 0
5 04/18/2016 1
5 02/14/2017 1
5 07/23/2018 0
5 09/07/2019 0
5 03/29/2020 0
5 05/18/2021 0
6 04/17/2012 1
6 12/13/2013 1
6 03/14/2015 0
6 08/11/2017 0
6 04/15/2018 1
6 08/18/2018 1
7 03/17/2013 1
7 05/01/2015 1
7 01/15/2016 1
7 08/14/2019 0
7 10/13/2020 0
7 12/19/2020 1
7 02/04/2021 1
7 06/30/2021 0
7 10/31/2022 0
8 02/13/2009 1
8 05/20/2010 1
8 07/03/2012 1
8 04/18/2016 1
8 09/10/2016 1
;;;;
... View more