Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65123

Count number of observations that satisfy conditions based on observation value

$
0
0
Dear Statalist,
I have a problem related to counting. I have tried to find similar topics on the forum but didn't find any. In the following example, I would like to find whether event 1 and 2 happen at similar time (related). If in company 1, event A takes place on 25-Apr-06 (obs. 5), I would like to count the number of event B happens within 30 days before or after the date of event A. In this example, obs. 6 satisfies the condition. Obs. 4 does not fit since it is also event A. Obs. 8 does not fit since it is with another company. So for obs. 5, the number of related obs. should be 1.
Obs company event A event B n_related? date
1 1 1 0 12-Dec-05
2 1 0 1 23-Dec-05
3 1 1 0 24-Feb-06
4 1 1 0 29-Mar-06
5 1 1 0 25-Apr-06
6 1 0 1 20-May-06
7 1 0 1 1-Jun-06
8 2 0 1 23-Apr-06
9 2 1 0 26-Jul-06
10 2 0 1 25-Aug-06
11 2 0 1 25-Sep-06
12 2 1 0 25-Oct-06
13 2 0 1 25-Oct-06
14 2 1 0 24-Nov-06
I am puzzled about how to use observation value as count criteria. And how to record count results?

Any help would be much appreciated. Many thanks in advance.

Yang

Viewing all articles
Browse latest Browse all 65123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>