generated from opensafely/research-template
/
an_coxbytime_R2.do
64 lines (49 loc) · 1.52 KB
/
an_coxbytime_R2.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
cap log close
log using analysis/output/an_coxbytime_R2, replace t
*changes for R2
*restrict to the CC bmi/smok population
*implement (outcome-specific) MI for ethnicity
use analysis/cr_append_process_data, clear
*R2
drop if obese4cat_withmiss==.
drop if smoke==.
safetab group
drop if region_real==.
safetab group
gen id=_n
streset, id(id)
***Composite***
*vs 2017_19-flu controls
preserve
keep if group==1|group==2
stsplit timesinceentry, at(22, 82, 1000)
stcox i.exposed##i.timesinceentry age1 age2 age3 male i.stp
estimates save analysis/output/models/an_coxbytime_R2_COMPOSITEvsflu_MINADJ, replace
restore
*vs 2019 general pop age/sex/stp matched controls
preserve
keep if group==1|group==4
stsplit timesinceentry, at(22, 82, 1000)
stcox i.exposed##i.timesinceentry, strata(setid)
estimates save analysis/output/models/an_coxbytime_R2_COMPOSITEvs2019gp_MINADJ, replace
restore
***Death***
*vs 2017_19-flu controls
preserve
include analysis/stsetfordeath1ocare.doi
streset, id(id)
keep if group==1|group==2
stsplit timesinceentry, at(22, 82, 1000)
stcox i.exposed##i.timesinceentry age1 age2 age3 male i.stp
estimates save analysis/output/models/an_coxbytime_R2_DEATHvsflu_MINADJ, replace
restore
*vs 2019 general pop controls
preserve
include analysis/stsetfordeath1ocare.doi
streset, id(id)
keep if group==1|group==4
stsplit timesinceentry, at(22, 82, 1000)
stcox i.exposed##i.timesinceentry, strata(setid)
estimates save analysis/output/models/an_coxbytime_R2_DEATHvs2019gp_MINADJ, replace
restore
log close