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
Impact of an average change on dependent variable over timeHello! For my thesis I wanted to test a hypothesis which requires a model that I wouldn't know how t…
xtprobit margin problemHello to All Stata Users! HTML Code: xtoprobit y x z, vce(cluster id) is the model I run . However…
merging datasets with different dimensionsHi all, I would like to merge together 16 datasets which are defined by country and are made as fol…
Using reghdfe command with if-statementsHello, bit of a complex one here: I’m currently working as a research assistant, using my superviso…
AR(1) is insignificant in difference GMMHello ! I am trying to estimate the following model in both difference and system GMM. However, the…
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