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
Tried several variations...need help with graphing a predicted probabilities plot with twoway scatter plot and splinedHi Statalist, I cannot figure out how to do this... the attached graph is exactly what we want, but …
match age and genderHello, I would like to know how to match 2:1 for age and gender using same sample of individuals. I …
GLS for non-linear equationln (Pit) = a*ln(Rit + b*Vit) + uit I want to estimate a, b for wide panel data (i = 1~16, t = 2007~…
Trying to run a predicted probabilities plot with a twoway scatterplot with a splineI accidentally created two threads of the same thing …
data management, creating new variables in one data set based on information in another data baseHello All, I hope this email finds you well! I have two databases one includes my raw data, and th…
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