Hi! My dataset is like this one ID DATE STATUS 1 31/01/2016 0 1 31/05/2016 1 1 28/02/2017 0 2 28/02/2018 1 2 31/05/2018 1 3 31/01/2016 1 3 31/03/2016 1 3 31/05/2016 0 4 31/01/2016 1 4 31/07/2016 0 4 28/02/2017 1 5 31/01/2016 0 5 31/05/2016 1 5 28/02/2017 1 You consider status=1 as default and status=0 'in bonis'. For each ID, I have to calculate the days between: - if it starts with default (status=1) and it continues always with default (like ID=2) -> calculate the days between the first observation date (28/02) and today - if it starts with default (status=1) and it continues with in bonis (status=0) (like ID=3) -> calculate the days between the last default date (31/03) and in bonis date - if it starts with bonis (status=0) and it continues with default (status=1) (like ID=5) -> calculate the days between the first default date (31/05) and today - if it starts with default (status=1), it continues with in bonis (status=0) and it returns in default (like ID=4) -> calculate the days between the first default date (31/01) and in bonis date (31/07), the days between the Second default date (28/02) and today - if it starts with in bonis (status=0) it continues with default (status=1) and it returns in bonis (like ID=1) -> calculate the days between the default date (31/05) and in bonis date Thank you so much to everyone who answers me soon!
... View more