generated from opensafely/research-template
/
an_covidvsnoncovid_agesex.do
71 lines (60 loc) · 1.76 KB
/
an_covidvsnoncovid_agesex.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
67
68
69
70
71
cap log close
log using ./analysis/output/an_covidvsnoncovid_agesex, replace t
cap prog drop baselogistic
prog define baselogistic
syntax , age(string) addvariable(string)
cap logistic _d `age' ///
i.male ///
i.`addvariable'
end
use ./analysis/cr_create_analysis_dataset_STSET_ONSCSDEATH.dta, clear
gen coviddeath = onsdeath==1 if _d==1
replace coviddeath= 0 if _d==0
gen noncoviddeath = onsdeath>1 if _d==1
replace noncoviddeath= 0 if _d==0
tab coviddeath
tab noncoviddeath
foreach run of any covid noncovid {
foreach addvariable of any asthmacat ///
cancer_exhaem_cat ///
cancer_haem_cat ///
chronic_cardiac_disease ///
reduced_kidney_function_cat ///
dialysis ///
chronic_liver_disease ///
chronic_respiratory_disease ///
diabcat ///
ethnicity ///
htdiag_or_highbp ///
bpcat ///
hypertension ///
imd ///
obese4cat ///
bmicat ///
organ_transplant ///
other_immunosuppression ///
other_neuro ///
ra_sle_psoriasis ///
smoke ///
smoke_nomiss ///
spleen ///
stroke_dementia {
cap logistic `run'death age1 age2 age3 male i.`addvariable'
if _rc==0{
estimates
estimates save ./analysis/output/models/an_covidvsnoncovid_agesex_`run'_`addvariable', replace
}
else di "MODEL DID NOT FIT (adding `addvariable')"
}
cap logistic `run'death age1 age2 age3 i.male
if _rc==0{
estimates
estimates save ./analysis/output/models/an_covidvsnoncovid_agesex_`run'_MALE, replace
}
cap logistic `run'death i.agegroup i.male
if _rc==0{
estimates
estimates save ./analysis/output/models/an_covidvsnoncovid_agesex_`run'_AGEGROUP, replace
}
}
log close