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]
Related Posts with Problem with generating counts of unique episodes within an ID based on the specific rule
Omitted values while doing regression with fixed effectsStatalist forum, I am trying to do 4 regression models with fixed effects. However, when I run the …
error using etpoissonHi, I was reviewing the example in the Treatment Effects user guide on page 68 where it uses the fo…
Coefficient of the interaction term of AFT modelDear Statalist, I have a question about the explanation of coefficients of interactions terms of the…
Weighting European Social SurveyHello everyone, Does anyone here know when to use each weight in the European Social Survey? I'm us…
How to keep first record but drop missing in longHI all, I have a dataset in long-format and would like to drop information so that I can just keep …
Subscribe to:
Post Comments (Atom)
0 Response to Problem with generating counts of unique episodes within an ID based on the specific rule
Post a Comment