generated from opensafely/research-template
/
an_cox_imputed.do
63 lines (45 loc) · 1.35 KB
/
an_cox_imputed.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
********************************************************************************
*
* Do-file: an_cox_imputed.do
*
* Project: SGTF CFR
*
* Programmed by: Daniel Grint
*
* Data used: output/cr_imputed_dataset.dta
*
* Data created: output/an_imputed_eth5
* output/an_imputed_eth2
*
* Other output: an_cox_imputed.log
*
*
********************************************************************************
*
* Purpose: This do-file imputes missing ethnicity data
*
********************************************************************************
* Open a log file
cap log close
log using ./logs/an_cox_imputed, replace t
clear
use ./output/cr_imputed_dataset.dta
* DROP MISSING UTLA
noi di "DROPPING MISSING UTLA DATA"
drop if utla_group==""
* DROP IF NO DATA ON SGTF
noi di "DROPPING NO SGTF DATA"
drop if has_sgtf==0
noi di "SUBSETTING ON COX CENSORED POPULATION"
keep if cox_pop==1
tab sgtf cox_death, row
* Declare survival data
mi stset stime_death, origin(study_start) fail(cox_death) scale(1) id(patient_id)
* Stratified by region
mi estimate, eform: stcox i.sgtf i.male ib1.imd ib1.eth2 ib1.smoke_nomiss2 ib1.obese4cat ib1.hh_total_cat ///
ib1.rural_urban5 ib0.comorb_cat ib1.start_week age1 age2 age3 i.home_bin ///
, strata(utla_group)
estimates save ./output/an_imputed_eth2, replace
* N (events)
tab sgtf cox_death if e(sample)
log close