generated from opensafely/research-template
/
subgroup_data_setup.do
119 lines (71 loc) · 3.04 KB
/
subgroup_data_setup.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/****************************************************************/
/* Project repo: opensafely/lockdown-and-vulnerable groups */
/* Program author: Scott Walter (Git: SRW612) */
/* Data used: output/measure_dva_rate.csv */
/* output/measure_intdis_rate.csv */
/* output/measure_RCGPsafeguard_rate.csv */
/* Outputs: output/dva_female.dta */
/* output/dva_male.dta */
/* output/intdis_sub14.dta */
/* output/intdis_over14.dta */
/* output/safeguard_sub18.dta */
/* Purpose: Create dta files for specific subgroups */
/* as well as for all groups combined */
/****************************************************************/
/* PREAMBLE */
global dir "`c(pwd)'"
*global dir "C:/Users/dy21108/OneDrive - University of Bristol/Documents/GitHub/lockdown-and-vulnerable-groups"
mkdir "$dir/output/diagnostics"
/*** SETUP DATA - Domestic violence and abuse ***/
import delimited using "$dir/output/measure_dva_rate.csv", clear
*Females only
keep if sex=="F"
rename consultations consultations_f
rename population population_f
rename value value_f
save "$dir/output/dva_female.dta", replace
*Males only
import delimited using "$dir/output/measure_dva_rate.csv", clear
keep if sex=="M"
rename consultations consultations_m
rename population population_m
rename value value_m
save "$dir/output/dva_male.dta", replace
*Females and males combined
merge m:1 date dva using "$dir/output/dva_female.dta"
gen consultations=consultations_f + consultations_m
gen population=population_f + population_m
gen value=consultations/population
drop sex consultations_f consultations_m population_f population_m value_f value_m _merge
save "$dir/output/dva_all.dta", replace
/*** SETUP DATA - Intellectual disability ***/
import delimited using "$dir/output/measure_intdis_rate.csv", clear
*Age<14
keep if age14==0
rename consultations consultations_sub14
rename population population_sub14
rename value value_sub14
save "$dir/output/intdis_sub14.dta", replace
*Age>=14
import delimited using "$dir/output/measure_intdis_rate.csv", clear
keep if age14==1
rename consultations consultations_over14
rename population population_over14
rename value value_over14
save "$dir/output/intdis_over14.dta", replace
*All ages combined
merge m:1 date intdis using "$dir/output/intdis_sub14.dta"
gen consultations=consultations_over14 + consultations_sub14
gen population=population_over14 + population_sub14
gen value=consultations/population
drop age14 consultations_over14 consultations_sub14 population_over14 population_sub14 value_over14 value_sub14 _merge
save "$dir/output/intdis_all.dta", replace
/*** SETUP DATA - Child safeguarding ***/
import delimited using "$dir/output/measure_RCGPsafeguard_rate.csv", clear
*Age<18
keep if age18==0
save "$dir/output/RCGPsafeguard_sub18.dta", replace
/*** SETUP DATA - Covid weekly counts of new cases ***/
*Get Covid weekly case counts;
import delimited using "$dir/output/CovidNewCaseCounts.csv", clear
save "$dir/output/CovidNewCaseCounts.dta", replace