-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable_2.do
More file actions
317 lines (280 loc) · 9 KB
/
table_2.do
File metadata and controls
317 lines (280 loc) · 9 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
****************************************************
****************************************************
****************************************************
****************************************************
****************************************************
* TAbLE 2
****************************************************
*cd "...set working directory"
use table2_data, clear
gsort study -q9date
duplicates drop study, force
file open prep using table_2.csv, write replace
file write prep ", month 1, month 1-6, month 7-12, month 13-18, total"
file write prep _n"Attendance"
count
local N=r(N)
foreach var in attend_all_ attend_allt_ ret3_ attend_event exit_before_ exit_during_ {
count if `var'1==1
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if `var'6==1
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if `var'12==1
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if `var'18==1
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
count if `var'total==1
local ntot=r(N)
local ptot= string(round(100*`ntot'/`N',0.1))
if strpos("`p1'",".")==0 local p1="`p1'"+".0"
if strpos("`p6'",".")==0 local p6="`p6'"+".0"
if strpos("`p12'",".")==0 local p12="`p12'"+".0"
if strpos("`p18'",".")==0 local p18="`p18'"+".0"
if strpos("`ptot'",".")==0 local ptot="`ptot'"+".0"
file write prep _n "`: var label `var'1', `n1' (`p1'%),`n6' (`p6'%),`n12' (`p12'%),`n18' (`p18'%), `ntot' (`ptot'%)"
}
***********REASONS FOR EXIT
file write prep _n"Reasons for exit"
*use table2_data, clear
levelsof exit_reason, local(levels)
local varname : var label exit_reason
foreach l of local levels {
local lbe : value label exit_reason
local vlabel : label `lbe' `l'
count if exit_during_1==1 & exit_reason!=.
local N=r(N)
count if exit_during_1==1 & exit_reason ==`l'
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if exit_during_6==1 & exit_reason!=.
local N=r(N)
count if exit_during_6==1 & exit_reason ==`l'
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if exit_during_12==1 & exit_reason!=.
local N=r(N)
count if exit_during_12==1 & exit_reason ==`l'
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if exit_during_18==1 & exit_reason!=.
local N=r(N)
count if exit_during_18==1 & exit_reason ==`l'
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
count if exit_during_total==1 & exit_reason!=.
local N=r(N)
count if exit_during_tot==1 & exit_reason ==`l'
local ntot=r(N)
local ptot= string(round(100*`ntot'/`N',0.1))
if strpos("`p1'",".")==0 local p1="`p1'"+".0"
if strpos("`p6'",".")==0 local p6="`p6'"+".0"
if strpos("`p12'",".")==0 local p12="`p12'"+".0"
if strpos("`p18'",".")==0 local p18="`p18'"+".0"
if strpos("`ptot'",".")==0 local ptot="`ptot'"+".0"
file write prep _n " `vlabel', `n1' (`p1'%),`n6' (`p6'%),`n12' (`p12'%),`n18' (`p18'%), `ntot' (`ptot'%)"
}
file write prep _n" Other reasons (not mutually exclusive):"
foreach var in q9_1_2_1 q9_1_2_2 q9_1_2_3 q9_1_2_4 q9_1_2_5 q9_1_2_6 q9_1_2_7 {
local varname : var label `var'
count if exit_during_1==1 & exit_reason!=.
*& exit_reason==5
local N=r(N)
count if exit_during_1==1 & `var' ==1
*& exit_reason==5
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if exit_during_6==1 & exit_reason!=.
*& exit_reason==5
local N=r(N)
count if exit_during_6==1 & `var' ==1
*& exit_reason==5
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if exit_during_12==1 & exit_reason!=.
*& exit_reason==5
local N=r(N)
count if exit_during_12==1 & `var' ==1
*& exit_reason==5
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if exit_during_18==1 & exit_reason!=.
*& exit_reason==5
local N=r(N)
count if exit_during_18==1 & `var' ==1
*& exit_reason==5
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
count if exit_during_total==1 & exit_reason!=.
*& exit_reason==5
local N=r(N)
count if exit_during_tot==1 & `var' ==1
*& exit_reason==5
local ntot=r(N)
local ptot= string(round(100*`ntot'/`N',0.1))
if strpos("`p1'",".")==0 local p1="`p1'"+".0"
if strpos("`p6'",".")==0 local p6="`p6'"+".0"
if strpos("`p12'",".")==0 local p12="`p12'"+".0"
if strpos("`p18'",".")==0 local p18="`p18'"+".0"
if strpos("`ptot'",".")==0 local ptot="`ptot'"+".0"
file write prep _n " `varname', `n1' (`p1'%),`n6' (`p6'%),`n12' (`p12'%),`n18' (`p18'%), `ntot' (`ptot'%)"
}
**********contracaption alignment
file write prep _n "Contraception alignment"
foreach var in at_ {
count if `var'1==1
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if `var'6==1
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if `var'12==1
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if `var'18==1
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
count if `var'total==1
local ntot=r(N)
local ptot= string(round(100*`ntot'/`N',0.1))
if strpos("`p1'",".")==0 local p1="`p1'"+".0"
if strpos("`p6'",".")==0 local p6="`p6'"+".0"
if strpos("`p12'",".")==0 local p12="`p12'"+".0"
if strpos("`p18'",".")==0 local p18="`p18'"+".0"
if strpos("`ptot'",".")==0 local ptot="`ptot'"+".0"
file write prep _n " `: var label `var'1', `n1' ,`n6' ,`n12' ,`n18', `ntot'"
}
*
foreach var in r_ rd_ nocx_ {
local varname : var label `var'1
count if at_1==1
local N=r(N)
count if at_1==1 & `var'1 ==1
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if at_6==1
*& exit_reason==5
local N=r(N)
count if at_6==1 & `var'6 ==1
*& exit_reason==5
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if at_12==1
*& exit_reason==5
local N=r(N)
count if at_12==1 & `var'12 ==1
*& exit_reason==5
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if at_18==1
*& exit_reason==5
local N=r(N)
count if at_18==1 & `var'18 ==1
*& exit_reason==5
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
count if at_total==1
*& exit_reason==5
local N=r(N)
count if at_tot==1 & `var'tot ==1
*& exit_reason==5
local ntot=r(N)
local ptot= string(round(100*`ntot'/`N',0.1))
if strpos("`p1'",".")==0 local p1="`p1'"+".0"
if strpos("`p6'",".")==0 local p6="`p6'"+".0"
if strpos("`p12'",".")==0 local p12="`p12'"+".0"
if strpos("`p18'",".")==0 local p18="`p18'"+".0"
if strpos("`ptot'",".")==0 local ptot="`ptot'"+".0"
file write prep _n " `varname', `n1' (`p1'%),`n6' (`p6'%),`n12' (`p12'%),`n18' (`p18'%), `ntot' (`ptot'%)"
}
file write prep _n "TDF-DP adherence measures"
****ADHERNECE DENOMINATOR
use table2_data, clear
gsort study -q9date
duplicates drop study, force
count
local N=r(N)
**use adherence data separately
clear
use TDF_merged_visits
** N
count if month==1
local N1=r(N)
count if month==4
local N4=r(N)
count if month==12
local N12=r(N)
count if month==18
local N18=r(N)
file write prep _n " N with results, `N1',`N4',`N12',`N18', N/A"
** new categories:
count if tdf_catD==2 & month==1
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if tdf_catD==2 & month==4
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if tdf_catD==2 & month==12
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if tdf_catD==2 & month==18
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
file write prep _n " High adherence levels (% of total), `n1' (`p1'%),`n6' (`p6'%),`n12' (`p12'%),`n18' (`p18'%), N/A"
count if month==1
local N=r(N)
count if tdf_catD==2 & month==1
local n1=r(N)
local p1= string(round(100*`n1'/`N',0.1))
count if month==4
local N=r(N)
count if tdf_catD==2 & month==4
local n6=r(N)
local p6= string(round(100*`n6'/`N',0.1))
count if month==12
local N=r(N)
count if tdf_catD==2 & month==12
local n12=r(N)
local p12= string(round(100*`n12'/`N',0.1))
count if month==18
local N=r(N)
count if tdf_catD==2 & month==18
local n18=r(N)
local p18= string(round(100*`n18'/`N',0.1))
file write prep _n " High adherence levels (% of tested), `n1' (`p1'%),`n6' (`p6'%),`n12' (`p12'%),`n18' (`p18'%), N/A"
* to add .0 to numbers with no decimals for consistent style
if strpos("`p1'",".")==0 local p1="`p1'"+".0"
if strpos("`p6'",".")==0 local p6="`p6'"+".0"
if strpos("`p12'",".")==0 local p12="`p12'"+".0"
if strpos("`p18'",".")==0 local p18="`p18'"+".0"
if strpos("`ptot'",".")==0 local ptot="`ptot'"+".0"
replace tdf_quant=0 if tdf_quant==.
summ tdf_quant if month==1, d
local med=r(p50)
local lb=r(p25)
local ub=r(p75)
file write prep _n " Median TFV-DP levels (IQR), `med' (`lb'-`ub'),"
summ tdf_quant if month==4, d
local med=r(p50)
local lb=r(p25)
local ub=r(p75)
file write prep "`med' (`lb'-`ub'),"
summ tdf_quant if month==12, d
local med=r(p50)
local lb=r(p25)
local ub=r(p75)
file write prep "`med' (`lb'-`ub'),"
summ tdf_quant if month==18, d
local med=r(p50)
local lb=r(p25)
local ub=r(p75)
file write prep "`med' (`lb'-`ub'),"
summ tdf_quant, d
local med=r(p50)
local lb=r(p25)
local ub=r(p75)
file write prep "`med' (`lb'-`ub'),"
file close prep