I have a dataset with approx. 29,000 entries related to approx. 3000 unique individuals’ admission and departure dates to and from a service over a period of time.
I’m trying to collapse each individuals’ service utilisation into discrete episodes in two separate ways:
1) Using a 30-day-gap exit criterion, meaning that all stays in the service in which the gap from one exit to the next entry is less than 30 days are considered to be part of one discrete episode. Thus, I need to build a formula that will allow me to check to see if there is a 30-day gap between when a person left and then re-entered the service (i.e. to see if an individual left the service for a period of 30 days before their next entry) and then sum the number of episodes associated with each unique individual in the service based on this 30-day exit criterion. This formula would then need to be applied to the whole dataset.
2)The same as above except using a 1-day-gap exit criterion.
Any help or direction with figuring out how best to go about doing this would be greatly appreciated.
Thanks in advance !