generated from opensafely/research-template
/
cr_imputed_dataset.do
66 lines (49 loc) · 1.31 KB
/
cr_imputed_dataset.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
64
65
66
********************************************************************************
*
* Do-file: cr_imputed.do
*
* Project: SGTF CFR
*
* Programmed by: Daniel Grint
*
* Data used: output/cr_analysis_dataset.dta
*
* Data created: output/cr_imputed_dataset.dta
*
* Other output: cr_imputed.log
*
*
********************************************************************************
*
* Purpose: This do-file imputes missing ethnicity data
*
********************************************************************************
* Open a log file
cap log close
log using ./logs/cr_imputed, replace t
clear
use ./output/cr_analysis_dataset.dta
recode eth2 6=. 5=0
tab eth2, m
egen inc = rowmiss(age1 age2 age3 male obese4cat smoke_nomiss imd comorb_cat region ///
rural_urban hh_total_cat home_bin sgtf start_week cox_death)
keep if inc==0
mi set wide
mi register imputed eth2
mi impute logit eth2 ///
age1 age2 age3 ///
i.male ///
i.obese4cat ///
i.smoke_nomiss ///
i.imd ///
i.comorb_cat ///
i.region ///
i.rural_urban ///
i.hh_total_cat ///
i.home_bin ///
i.sgtf ///
i.start_week ///
cox_death, add(10) rseed(19022021) noisily iter(20)
label data "SGTF CFR IMPUTED DATASET: $S_DATE"
save ./output/cr_imputed_dataset.dta, replace
log close