Hi,
I have a dataset with a large amount of sites with sub-units, with reoccurring year classes at the same sites. Once in a while an event takes place on one or more of the subunits (event=1, no event=missing). I need to find out the number of units at a site having an event within +/- three days of another unit so I can calculate the percent of the total units going through an event at the same time (same time being within +/- 3 days).
The dataset is tsset with year class, site and unit as identifiers (I made an unique ID from these three variables). It is easy enough to get the date three days before or three days after an event at a single unit, but I'm at a loss how to code to get all units at the site having an event withing the given time span. Hopefull I'm just tired on a friday afternoon, and this is really easy
I've attached data from two sites so you can see the structure.
Hope you can help, thanks in advance!
I have a dataset with a large amount of sites with sub-units, with reoccurring year classes at the same sites. Once in a while an event takes place on one or more of the subunits (event=1, no event=missing). I need to find out the number of units at a site having an event within +/- three days of another unit so I can calculate the percent of the total units going through an event at the same time (same time being within +/- 3 days).
The dataset is tsset with year class, site and unit as identifiers (I made an unique ID from these three variables). It is easy enough to get the date three days before or three days after an event at a single unit, but I'm at a loss how to code to get all units at the site having an event withing the given time span. Hopefull I'm just tired on a friday afternoon, and this is really easy

I've attached data from two sites so you can see the structure.
Hope you can help, thanks in advance!
Comment