-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataprep.do
337 lines (277 loc) · 8.96 KB
/
dataprep.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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/********************************************************************
Purpose: Donwloading NHANES data for Wan et al pesticide-ckd paper.
*********************************************************************/
*clear the space;
clear all
/*Change working directory*/
cd "C:\Users\Grace\Desktop\project publication\try\2001-02"
*2001-2002
*bmiwc
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/BMX_B.XPT", clear
keep seqn bmxwaist
sort seqn
save bmiwc, replace
*bloodpressure
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/BPX_B.XPT", clear
keep seqn bpxsy1 bpxdi1
sort seqn
save bloodpressure, replace
*fastingglucose
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/L10AM_B.XPT", clear
keep seqn lbxglu
sort seqn
save fastingglucose, replace
*serumcreatinine
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/L40_B.XPT", clear
keep seqn lbdscr
sort seqn
save serumcreatinine, replace
*metal
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/L06_B.XPT", clear
keep seqn lbxbcd
sort seqn
save metal, replace
*herbicide
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/L26PP_B.XPT", clear
keep seqn urxcpm urxopm urx24d wtspp2yr
sort seqn
save herbicide, replace
*smoke
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/SMQ_B.XPT", clear
keep seqn smq020 smq040
sort seqn
save smoke, replace
*alcohol
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/ALQ_B.XPT", clear
keep seqn alq110
sort seqn
save alcohol, replace
*hypertension
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/BPQ_B.XPT", clear
keep seqn bpq040a
sort seqn
save hypertension, replace
*diabetes
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/DIQ_B.XPT", clear
keep seqn diq010 diq070
sort seqn
save diabetes, replace
*demographic
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2001-2002/DEMO_B.XPT", clear
keep seqn riagendr ridageyr ridreth1 dmdeduc2 indfmpir wtint2yr wtmec2yr sdmvpsu sdmvstra
sort seqn
save demographic, replace
*merge for 2001-2002 /*Change working directory*/
merge seqn using demographic bmiwc bloodpressure fastingglucose ///
serumcreatinine metal herbicide smoke alcohol hypertension diabetes
tab _merge
drop _merge*
gen wave = 1
cd "C:\Users\Grace\Desktop\project publication\try\merged"
sort seqn
save wave1, replace
*2003-2004
/*Change working directory*/
cd "C:\Users\Grace\Desktop\project publication\try\2003-04"
*bmiwc
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/BMX_C.XPT", clear
keep seqn bmxwaist
sort seqn
save bmiwc, replace
*bloodpressure
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/BPX_C.XPT", clear
keep seqn bpxsy1 bpxdi1
sort seqn
save bloodpressure, replace
*fastingglucose
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/L10AM_C.XPT", clear
keep seqn lbxglu
sort seqn
save fastingglucose, replace
*serumcreatinine
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/L40_C.XPT", clear
keep seqn lbxscr
sort seqn
save serumcreatinine, replace
*metal
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/L06BMT_C.XPT", clear
keep seqn lbxbcd
sort seqn
save metal, replace
*herbicide
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/L26UPP_C.XPT", clear
keep seqn wtsc2yr urx24d urxape urxbsm urxchs
sort seqn
save herbicide, replace
*smoke
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/SMQ_C.XPT", clear
keep seqn smq020 smq040
sort seqn
save smoke, replace
*alcohol
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/ALQ_C.XPT", clear
keep seqn alq110
sort seqn
save alcohol, replace
*hypertension
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/BPQ_C.XPT", clear
keep seqn bpq040a
sort seqn
save hypertension, replace
*diabetes
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/DIQ_C.XPT", clear
keep seqn diq010 diq070
sort seqn
save diabetes, replace
*demographic
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/DEMO_C.XPT", clear
keep seqn riagendr ridageyr ridreth1 dmdeduc2 indfmpir wtint2yr wtmec2yr sdmvpsu sdmvstra
sort seqn
save demographic, replace
*merge for 2003-2004 /*Change working directory*/
merge seqn using demographic bmiwc bloodpressure fastingglucose ///
serumcreatinine metal herbicide smoke alcohol hypertension diabetes
tab _merge
drop _merge*
gen wave = 2
cd "C:\Users\Grace\Desktop\project publication\try\merged"
sort seqn
save wave2, replace
*2007-2008
/*Change working directory*/
cd "C:\Users\Grace\Desktop\project publication\try\2007-08"
*bmiwc
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/BMX_E.XPT", clear
keep seqn bmxwaist
sort seqn
save bmiwc, replace
*bloodpressure
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/BPX_E.XPT", clear
keep seqn bpxsy1 bpxdi1
sort seqn
save bloodpressure, replace
*fastingglucose
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/GLU_E.XPT", clear
keep seqn lbxglu
sort seqn
save fastingglucose, replace
*serumcreatinine
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/BIOPRO_E.XPT", clear
keep seqn lbxscr
sort seqn
save serumcreatinine, replace
*metal
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/PBCD_E.XPT", clear
keep seqn lbxbcd
sort seqn
save metal, replace
*herbicide
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/UPHOPM_E.XPT", clear
keep seqn wtsc2yr urx24d urxcpm urxmal urxopm
sort seqn
save herbicide, replace
*smoke
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/SMQ_E.XPT", clear
keep seqn smq020 smq040
sort seqn
save smoke, replace
*alcohol
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/ALQ_E.XPT", clear
keep seqn alq110
sort seqn
save alcohol, replace
*hypertension
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/BPQ_E.XPT", clear
keep seqn bpq040a
sort seqn
save hypertension, replace
*diabetes
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/DIQ_E.XPT", clear
keep seqn diq010 did070
sort seqn
save diabetes, replace
*demographic
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2007-2008/DEMO_E.XPT", clear
keep seqn riagendr ridageyr ridreth1 dmdeduc2 indfmpir wtint2yr wtmec2yr sdmvpsu sdmvstra
sort seqn
save demographic, replace
*merge for 2007-2008 /*Change working directory*/
merge seqn using demographic bmiwc bloodpressure fastingglucose ///
serumcreatinine metal herbicide smoke alcohol hypertension diabetes
tab _merge
drop _merge*
gen wave = 3
cd "C:\Users\Grace\Desktop\project publication\try\merged"
sort seqn
save wave3, replace
*2009-2010
/*Change working directory*/
cd "C:\Users\Grace\Desktop\project publication\try\2009-10"
*bmiwc
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/BMX_F.XPT", clear
keep seqn bmxwaist
sort seqn
save bmiwc, replace
*bloodpressure
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/BPX_F.XPT", clear
keep seqn bpxsy1 bpxdi1
sort seqn
save bloodpressure, replace
*fastingglucose
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/GLU_F.XPT", clear
keep seqn lbxglu
sort seqn
save fastingglucose, replace
*serumcreatinine
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/BIOPRO_F.XPT", clear
keep seqn lbxscr
sort seqn
save serumcreatinine, replace
*metal
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/PBCD_F.XPT", clear
keep seqn lbxbcd
sort seqn
save metal, replace
*herbicide
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/UPHOPM_F.XPT", clear
keep seqn wtsc2yr urx24d urxcpm urxmal urxopm
sort seqn
save herbicide, replace
*smoke
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/SMQ_F.XPT", clear
keep seqn smq020 smq040
sort seqn
save smoke, replace
*alcohol
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/ALQ_F.XPT", clear
keep seqn alq110
sort seqn
save alcohol, replace
*hypertension
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/BPQ_F.XPT", clear
keep seqn bpq040a
sort seqn
save hypertension, replace
*diabetes
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/DIQ_F.XPT", clear
keep seqn diq010 diq070
sort seqn
save diabetes, replace
*demographic
import sasxport5 "https://wwwn.cdc.gov/Nchs/Nhanes/2009-2010/DEMO_F.XPT", clear
keep seqn riagendr ridageyr ridreth1 dmdeduc2 indfmpir wtint2yr wtmec2yr sdmvpsu sdmvstra
sort seqn
save demographic, replace
*merge for 2009-2010 /*Change working directory*/
merge seqn using demographic bmiwc bloodpressure fastingglucose ///
serumcreatinine metal herbicide smoke alcohol hypertension diabetes
tab _merge
drop _merge*
gen wave = 4
cd "C:\Users\Grace\Desktop\project publication\try\merged"
sort seqn
save wave4, replace
*Full data
merge seqn using wave1 wave2 wave3 wave4
tab _merge
save alldat, replace