-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAge.do
More file actions
337 lines (307 loc) · 17.2 KB
/
Copy pathAge.do
File metadata and controls
337 lines (307 loc) · 17.2 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
***************TEMPLATE*********************************************************************************
*replace #SOURCE# with the Source table name
*replace #TABLE OUTPUT# with the filepath you plan to save to
*Copy the table name down the bottom of the syntax to append
***LPS*******************************************************************************************************
*clear
*use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\#SOURCE#"
*keep LLC_0001_stud_id llc_stamp_day llc_stamp_month llc_stamp_year mob dob dos source
*generate value=#
*drop #
*save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_#TABLE OUTPUT#.dta", replace
***ALSPAC****************************************************************************************************************************
**Mothers Wave 1
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave1m.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_1m_alspacage.dta", replace
**Mothers Wave 2
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave2m.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_2m_alspacage.dta", replace
**Mothers Wave 3
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave3m.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_3m_alspacage.dta", replace
**Mothers Wave 4
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave4m.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_4m_alspacage.dta", replace
**YP Wave 1
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave1yp.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_1yp_alspacage.dta", replace
**YP Wave 2
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave2yp.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_2yp_alspacage.dta", replace
**YP Wave 3
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave3yp.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_3yp_alspacage.dta", replace
**YP Wave 4
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave4yp.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age llc_stamp_month llc_stamp_day llc_stamp_year
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_4yp_alspacage.dta", replace
***BCS70****************************************************************************************************************************
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\CORE_denominator_file1.dta", replace
keep if cohort=="BCS70"
drop cohort
generate dob= 01
generate mob= 04
generate yob= 1970
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_bcs70age.dta", replace
***BIB****************************************************************************************************************************
*Submitted DOB (y and month)
***ELSA****************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ELSA_wave_9_ifs_derived_variables.dta"
keep LLC_0001_stud_id yob source
destring yob, replace
generate dob= 01
generate mob= 01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_ELSA_wave9derived_Age.dta", replace
***EPICN*********************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\EPICN_HLQ.dta"
keep LLC_0001_stud_id age dos source
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_HLQ_EPICN_Age.dta", replace
***EXCEED*********************************************************************************************************************************
*submitted
***FENLAND*********************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\FENLAND_P1.dta"
keep LLC_0001_stud_id source dos age source
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop age datbirth dos
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Sex&Gender\llc_0001_fenlandage.dta", replace
***GENSCOT*********************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\GENSCOT_DEMOGRAPHICS.dta"
keep LLC_0001_stud_id source mob yob source
generate dob= 01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_genscotagedemographic.dta", replace
***GLAD*********************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\GLAD_FILE2.dta"
keep LLC_0001_stud_id age dos source
destring age, replace
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop age datbirth dos
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_GLAD_AGE.dta", replace
***MCS**************************************************************************************************************************
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_basic_demographic_hhgrid"
keep LLC_0001_stud_id yob mob
generate dob= 01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_MCS_basic_dem_hhgrid_age.dta", replace
***NCDS58*****************************************************************************************************************************
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\CORE_denominator_file1.dta", replace
keep if cohort=="NCDS58"
drop cohort
generate dob= 01
generate mob= 05
generate yob= 1970
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_NCDS58age.dta", replace
***NEXTSTEP****************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NEXTSTEP_basic_demographic_data.dta"
keep LLC_0001_stud_id mob yob source
generate dob=01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_NEXTSTEP_age.dta", replace
***NICOLA****************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NICOLA_Wave1CAPI.dta"
keep LLC_0001_stud_id mob yob source
generate dob=01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth yob mob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_CAPI1_Nicola_Age.dta", replace
***NIHRBIO_COPING****************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NIHRBIO_COPING_Bioresource.dta"
keep LLC_0001_stud_id age dos source
destring age, replace
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop age datbirth dos
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_NIHRBIO_COPING_AGE.dta", replace
***NSHD46*************************************************************************************************************************
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\CORE_denominator_file1.dta", replace
keep if cohort=="NSHD46"
drop cohort
generate dob= 01
generate mob= 03
generate yob= 1946
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_nshd46agesociodemo.dta", replace
***SABRE*************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\SABRE_sociodemographic_visit3.dta"
keep LLC_0001_stud_id age llc_stamp_year llc_stamp_month llc_stamp_day source
generate dos=mdy(llc_stamp_month, llc_stamp_day, llc_stamp_year)
format dos %td
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop llc_stamp_day llc_stamp_month llc_stamp_year age datbirth dos
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_sabreagesociodemov3.dta", replace
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\TRACKC19_basicInfo.dta"
keep LLC_0001_stud_id age dos source
generate datbirth= dos-(age*365)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth dos age
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_trackc19basicinfoage.dta", replace
***TWINSUK*************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\TWINSUK_DEMOGRAPHICS.dta"
keep LLC_0001_stud_id yob source
generate dob= 01
generate mob= 01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_twinsuagedemographic.dta", replace
***UKHLS*************************************************************************************************************************
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\UKHLS_xsample.dta"
keep LLC_0001_stud_id yob source
generate dob= 01
generate mob= 01
generate datbirth=mdy(mob,dob,yob)
format datbirth %td
generate value=(td(01aug2022)-datbirth)/365
drop datbirth mob yob dob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_ukhls_xsample_age.dta", replace
*****append together
clear
use "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_4yp_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_3yp_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_2yp_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_1yp_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_4m_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_3m_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_2m_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_1m_alspacage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_bcs70age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_ELSA_wave9derived_Age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_HLQ_EPICN_Age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Sex&Gender\llc_0001_fenlandage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_genscotagedemographic.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_GLAD_AGE.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_MCS_basic_dem_hhgrid_age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_NCDS58age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_NEXTSTEP_age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_CAPI1_Nicola_Age.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_NIHRBIO_COPING_AGE.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_sabreagesociodemov3.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_nshd46agesociodemo.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_trackc19basicinfoage.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_twinsuagedemographic.dta"
append using "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Age\llc_0001_ukhls_xsample_age.dta"
**Delete Blanks
keep if value!=.
***Add Object***
generate object= "llc_age"
***Keep the oldest measure (Biggest value) 1 measure per participant****
bysort LLC_0001_stud_id object: egen rank=rank(-value), unique
keep if rank==1
duplicates report LLC_0001_stud_id
drop rank
***Save the raw file without additing in the missing participants****
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\llc_0001_harmonised_age.dta", replace