Hi everyone,
I have data on patients receiving certain medication captured as 9-months episodes. I need to calculate unique episodes that are spaced out by at least 3 months from each other (baed on the Baseline_month) and create a count of those unique episodes.
Currently, I have episodes that overlap, since each episode is a 9-month period.
For example, ID 30 has 6 overlapping episodes. However, ID 30 has only 2 unique episodes, if I apply the rule of at least 3 months apart between the Baseline_begins. So, ideally I need to have another variable that would be a count of unique episodes within a patient ID.
This count variable would look like this for ID 30: 1,1,1,1,2,2,.
I tried this code: bysort id:egen count= count(episode) if (Baseline_begins[_n]- Baseline_begins[_n-1])
But, I keep getting the maximum number of episodes, aka 6 for ID 30.
I would appreciate assistance with this problem!
id episode Baseline_begins
30 1 83
30 2 84
30 3 85
30 4 86
30 5 99
30 6 100
57 1 26
57 2 27
57 3 30
57 4 31
57 5 32
57 6 33
57 7 34
57 8 35
57 9 45
57 10 48
57 11 49
60 1 25
60 2 26
60 3 27
end
[/CODE]
0 Response to Problem with generating counts of unique episodes within an ID based on the specific rule
Post a Comment