-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prerequisite.do
709 lines (637 loc) · 32.1 KB
/
Prerequisite.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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
**Prerequisite Do-File**
**SB 14.09.2022
**Aim: Pull self-report data for key sociodemographic variables and save them to use consistent naming convention for uk llc harmonised variables
**Save Clean Files: S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables
**See Footnote for 'Date Splitting Apart Help'
*Glossary:
*Age-age
*Year of Birth- yob
*Ethnicity-ethnic
*Sex-sex
*Gender-gender
***CORE Denominator File**************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, cohort FROM [UKSERPUKLLC].[LLC_0001].[CORE_denominator_file1_20220801] where ukllc_status = '1' order by LLC_0001_stud_id") dsn (LLC_DB)
generate source="CORE_denominator_file1"
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\CORE_denominator_file1.dta", replace
***ALSPAC*****************************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, kz021, c993, c992 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave0y_v0001_20220531]") dsn (LLC_DB)
generate source="ALSPAC_wave0y"
generate llc_stamp_year=c993+1900
generate llc_stamp_month=c992
generate llc_stamp_day=01
replace llc_stamp_year=1991 if llc_stamp_year==.
replace llc_stamp_month=01 if llc_stamp_month==.
replace llc_stamp_day=01 if llc_stamp_day==.
drop c993 c992
rename kz021 sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave0y.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave0m_v0001_20220531]") dsn (LLC_DB)
generate source="ALSPAC_wave0m"
generate llc_stamp_year=2021
generate llc_stamp_month=01
generate llc_stamp_day=01
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave0m.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid1m_9620, covid1m_9621, covid1m_9622, covid1m_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave1m_v0001_20211101]") dsn (LLC_DB)
generate source="ALSPAC_wave1m"
generate llc_stamp_year=covid1m_9622
generate llc_stamp_month=covid1m_9621
generate llc_stamp_day=covid1m_9620
rename covid1m_9650 age
drop covid1m_9620 covid1m_9621 covid1m_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave1m.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid2m_9620, covid2m_9621, covid2m_9622, covid2m_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave2m_v0001_20211101]") dsn (LLC_DB)
generate source="ALSPAC_wave2m"
generate llc_stamp_year=covid2m_9622
generate llc_stamp_month=covid2m_9621
generate llc_stamp_day=covid2m_9620
rename covid2m_9650 age
drop covid2m_9620 covid2m_9621 covid2m_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave2m.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid3m_9620, covid3m_9621, covid3m_9622, covid3m_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave3m_v0001_20211101]") dsn (LLC_DB)
generate source="ALSPAC_wave3m"
generate llc_stamp_year=covid3m_9622
generate llc_stamp_month=covid3m_9621
generate llc_stamp_day=covid3m_9620
rename covid3m_9650 age
drop covid3m_9620 covid3m_9621 covid3m_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave3m.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid4m_9620, covid4m_9621, covid4m_9622, covid4m_0500, covid4m_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave4m_v0001_20220531]") dsn (LLC_DB)
generate source="ALSPAC_wave4m"
generate llc_stamp_year=covid4m_9622
generate llc_stamp_month=covid4m_9621
generate llc_stamp_day=covid4m_9620
rename covid4m_0500 ethnic
rename covid4m_9650 age
drop covid4m_9620 covid4m_9621 covid4m_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave4m.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid1yp_9620, covid1yp_9621, covid1yp_9622, covid1yp_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave1y_v0001_20211101]") dsn (LLC_DB)
generate source="ALSPAC_wave1yp"
generate llc_stamp_year=covid1yp_9622
generate llc_stamp_month=covid1yp_9621
generate llc_stamp_day=covid1yp_9620
rename covid1yp_9650 age
drop covid1yp_9620 covid1yp_9621 covid1yp_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave1yp.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid2yp_9620, covid2yp_9621, covid2yp_9622, covid2yp_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave2y_v0001_20211101]") dsn (LLC_DB)
generate source="ALSPAC_wave2yp"
generate llc_stamp_year=covid2yp_9622
generate llc_stamp_month=covid2yp_9621
generate llc_stamp_day=covid2yp_9620
rename covid2yp_9650 age
drop covid2yp_9620 covid2yp_9621 covid2yp_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave2yp.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid3yp_9620, covid3yp_9621, covid3yp_9622, covid3yp_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave3y_v0001_20211101]") dsn (LLC_DB)
generate source="ALSPAC_wave3yp"
generate llc_stamp_year=covid3yp_9622
generate llc_stamp_month=covid3yp_9621
generate llc_stamp_day=covid3yp_9620
rename covid3yp_9650 age
drop covid3yp_9620 covid3yp_9621 covid3yp_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave3yp.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, covid4yp_9620, covid4yp_9621, covid4yp_9622, covid4yp_9650 FROM [UKSERPUKLLC].[LLC_0001].[ALSPAC_wave4y_v0001_20220531]") dsn (LLC_DB)
generate source="ALSPAC_wave4yp"
generate llc_stamp_year=covid4yp_9622
generate llc_stamp_month=covid4yp_9621
generate llc_stamp_day=covid4yp_9620
rename covid4yp_9650 age
drop covid4yp_9620 covid4yp_9621 covid4yp_9622
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ALSPAC_wave4yp.dta", replace
***BCS70**********************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, ethnic, intdate FROM [UKSERPUKLLC].[LLC_0001].[BCS70_bcs6_v0001_1_20211101]") dsn (LLC_DB)
generate source="BCS70_bcs6"
generate llc_stamp_year=mod(intdate, 10000)
generate llc_stamp_month=01
generate llc_stamp_day=01
drop intdate
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\BCS70_bcs6.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw1_psex, cw1_enddate FROM [UKSERPUKLLC].[LLC_0001].[BCS70_COVID_w1_v0001_20211101]") dsn (LLC_DB)
keep LLC_0001_stud_id cw1_psex cw1_enddate
generate source="BCS70_COVID_w1"
generate llc_stamp_year=2020
generate llc_stamp_month=5
generate llc_stamp_day=cw1_enddate
drop cw1_enddate
rename cw1_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\BCS70_COVID_w1.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw2_psex, cw2_enddated, cw2_enddatem FROM [UKSERPUKLLC].[LLC_0001].[BCS70_COVID_w2_v0001_20211101]") dsn (LLC_DB)
keep LLC_0001_stud_id cw2_psex cw2_enddated cw2_enddatem
generate source="BCS70_COVID_w2"
generate llc_stamp_year=2020
generate llc_stamp_month=cw2_enddatem
generate llc_stamp_day=cw2_enddated
drop cw2_enddated
drop cw2_enddatem
rename cw2_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\BCS70_COVID_w2.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw3_psex, cw3_enddatem, cw3_enddated FROM [UKSERPUKLLC].[LLC_0001].[BCS70_COVID_w3_v0001_20211101]") dsn (LLC_DB)
generate source="BCS70_COVID_w3"
generate llc_stamp_year=2021
generate llc_stamp_month=cw3_enddatem
generate llc_stamp_day=cw3_enddated
drop cw3_enddated
drop cw3_enddatem
rename cw3_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\BCS70_COVID_w3.dta", replace
***BIB******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, bib_timestamp, bib_eth16cat, bib_sex FROM [UKSERPUKLLC].[LLC_0001].[BIB_SOCIODEMO_v0001_20220118]") dsn (LLC_DB)
generate source="BIB_SOCIODEMO"
generate llc_timestamp=dofc(bib_timestamp)
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
replace llc_stamp_year=2008 if llc_stamp_year==.
generate llc_stamp_month=month(llc_timestamp)
replace llc_stamp_month=01 if llc_stamp_month==.
generate llc_stamp_day=day(llc_timestamp)
replace llc_stamp_day=01 if llc_stamp_day==.
rename bib_eth16cat ethnic
drop bib_timestamp llc_timestamp
rename bib_sex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\BIB_SOCIODEMO.dta", replace
***ELSA******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, sex, cintdatd, cintdatm, cintdaty, ethnicity_arch FROM [UKSERPUKLLC].[LLC_0001].[ELSA_elsa_covid_w1_eul_v0001_20211101]") dsn (LLC_DB)
generate source="ELSA_elsa_covid_w1_eul"
generate llc_stamp_year=cintdaty
generate llc_stamp_month=cintdatm
generate llc_stamp_day=cintdatd
drop cintdatd cintdatm cintdaty
rename ethnicity_arch ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ELSA_elsa_covid_w1_eul.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, sex, cintdatd, cintdatm, cintdaty, ethnicity_arch FROM [UKSERPUKLLC].[LLC_0001].[ELSA_elsa_covid_w2_eul_v0001_20211101]") dsn (LLC_DB)
generate source="ELSA_elsa_covid_w2_eul"
generate llc_stamp_year=cintdaty
generate llc_stamp_month=cintdatm
generate llc_stamp_day=cintdatd
drop cintdatd cintdatm cintdaty
rename ethnicity_arch ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ELSA_elsa_covid_w2_eul.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, sex, iintdatd, iintdatm, iintdaty, indobyr FROM [UKSERPUKLLC].[LLC_0001].[ELSA_wave_9_ifs_derived_variables_v0001_20211101]") dsn (LLC_DB)
generate source="ELSA_wave_9_ifs_derived_variables"
generate llc_stamp_year=iintdaty
generate llc_stamp_month=iintdatm
generate llc_stamp_day=iintdatd
destring llc_stamp_year, replace
foreach var in llc_stamp_day llc_stamp_month {
destring `var', replace
}
drop iintdatd iintdatm iintdaty
rename indobyr yob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\ELSA_wave_9_ifs_derived_variables.dta", replace
***EPICN******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, doc_hlq, AGE_HLQ, ethnic, SEX FROM [UKSERPUKLLC].[LLC_0001].[EPICN_HLQ_v0001_20220405]") dsn (LLC_DB)
generate source="EPICN_HLQ"
generate llc_timestamp= date(doc_hlq, "DMY")
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
drop doc_hlq
rename llc_timestamp dos
rename AGE_HLQ age
rename SEX sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\EPICN_HLQ.dta", replace
***EXCEED******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, gen5, gen2, gen2b, timestamp FROM [UKSERPUKLLC].[LLC_0001].[EXCEED_exceed_selfcompletion_questionnaire_v0002_20220302]") dsn (LLC_DB)
generate source="exceed_selfcompletion_questionnaire"
generate llc_timestamp=dofc(timestamp)
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
drop timestamp llc_timestamp
rename gen5 ethnic
rename gen2 gender
rename gen2b sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\EXCEED_exceed_selfcompletion_questionnaire.dta", replace
***FENLAND******************************************************************************************************************************
clear
odbc load, exec("select * FROM [UKSERPUKLLC].[LLC_0001].[FENLAND_P1_v0001_20220810]") dsn (LLC_DB)
keep LLC_0001_stud_id appdate_attended_ukllc gq_eth_der sex g_ageattest_attended
rename g_ageattest_attended age
rename gq_eth_der ethnic
generate source="FENLAND_P1"
generate llc_timestamp= date(appdate_attended_ukllc, "DMY")
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
rename llc_timestamp dos
drop appdate_attended_ukllc
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\FENLAND_P1.dta", replace
***GENSCOT******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, yob, mob, sex, appt FROM [UKSERPUKLLC].[LLC_0001].[GENSCOT_DEMOGRAPHICS_v0001_20211101]") dsn (LLC_DB)
generate source="GENSCOT_DEMOGRAPHICS"
generate llc_timestamp=dofc(appt)
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
drop appt llc_timestamp
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\GENSCOT_DEMOGRAPHICS.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, gender, Ethnic_Origin, enddate FROM [UKSERPUKLLC].[LLC_0001].[GENSCOT_COVIDLIFE1_v0001_20211101]") dsn (LLC_DB)
generate source="GENSCOT_COVIDLIFE1"
generate temp=word(enddate,1)
generate llc_timestamp= date(temp, "DMY")
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
drop enddate temp llc_timestamp
rename Ethnic_Origin ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\GENSCOT_COVIDLIFE1.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, race, appt FROM [UKSERPUKLLC].[LLC_0001].[GENSCOT_ETHNIC_v0002_20220302]") dsn (LLC_DB)
generate source="GENSCOT_ETHNIC"
generate llc_timestamp= date(appt, "YMD")
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
rename race ethnic
drop appt llc_timestamp
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\GENSCOT_ETHNIC.dta", replace
***GLAD******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, Ethnicity, age, gender, sex, startdate_prepandemic FROM [UKSERPUKLLC].[LLC_0001].[GLAD_FILE2_v0001_20211101]") dsn (LLC_DB)
generate source="GLAD_FILE2"
generate temp=word(startdate_prepandemic,1)
generate llc_timestamp= date(temp, "YMD")
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
rename llc_timestamp dos
drop startdate_prepandemic temp
rename Ethnicity ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\GLAD_FILE2.dta", replace
***MCS*******************************************************************************************************************************
******CM******
*1
clear
odbc load, exec("select LLC_0001_stud_id, ADC11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs1_cm_derived_v0001_20211101]") dsn (LLC_DB)
generate source="mcs1_cm_derived"
generate llc_stamp_year=2003
generate llc_stamp_month=01
generate llc_stamp_day=01
rename ADC11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs1_cm_derived", replace
*2
clear
odbc load, exec("select LLC_0001_stud_id, BDC11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs2_cm_derived_v0001_20211101]") dsn (LLC_DB)
generate source="mcs2_cm_derived"
generate llc_stamp_year=2005
generate llc_stamp_month=01
generate llc_stamp_day=01
rename BDC11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs2_cm_derived", replace
*3
clear
odbc load, exec("select LLC_0001_stud_id, CDC11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs3_cm_derived_v0001_20211101]") dsn (LLC_DB)
generate source="MCS_mcs3_cm_derived"
generate llc_stamp_year=2007
generate llc_stamp_month=01
generate llc_stamp_day=01
rename CDC11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs3_cm_derived", replace
*4
clear
odbc load, exec("select LLC_0001_stud_id, DDC11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs4_cm_derived_v0001_20211101]") dsn (LLC_DB)
generate source="mcs4_cm_derived"
generate llc_stamp_year=2009
generate llc_stamp_month=01
generate llc_stamp_day=01
rename DDC11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs4_cm_derived", replace
******Parent******
*1
clear
odbc load, exec("select LLC_0001_stud_id, ADD11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs1_parent_derived_v0001_20211101]") dsn (LLC_DB)
generate source="mcs1_parent_derived"
generate llc_stamp_year=2003
generate llc_stamp_month=01
generate llc_stamp_day=01
rename ADD11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs1_parent_derived", replace
*2
clear
odbc load, exec("select LLC_0001_stud_id, BDD11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs2_parent_derived_v0001_20211101]") dsn (LLC_DB)
generate source="mcs2_parent_derived"
generate llc_stamp_year=2005
generate llc_stamp_month=01
generate llc_stamp_day=01
rename BDD11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs2_parent_derived", replace
*3
clear
odbc load, exec("select LLC_0001_stud_id, CDD11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs3_parent_derived_v0001_20211101]") dsn (LLC_DB)
generate source="MCS_mcs3_parent_derived"
generate llc_stamp_year=2007
generate llc_stamp_month=01
generate llc_stamp_day=01
rename CDD11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs3_parent_derived", replace
*4
clear
odbc load, exec("select LLC_0001_stud_id, DDD11E00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_mcs4_parent_derived_v0001_20211101]") dsn (LLC_DB)
generate source="mcs4_parent_derived"
generate llc_stamp_year=2009
generate llc_stamp_month=01
generate llc_stamp_day=01
rename DDD11E00 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_mcs4_parent_derived", replace
*Demographics
clear
odbc load, exec("select LLC_0001_stud_id, AHPDBM00, AHPDBY00 FROM [UKSERPUKLLC].[LLC_0001].[MCS_basic_demographic_hhgrid_v0001_20211101]") dsn (LLC_DB)
generate source="MCS_basic_demographic_hhgrid"
rename AHPDBM00 mob
rename AHPDBY00 yob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_basic_demographic_hhgrid", replace
*Covid1
clear
odbc load, exec("select LLC_0001_stud_id, cw1_psex, cw1_enddate FROM [UKSERPUKLLC].[LLC_0001].[MCS_COVID_w1_v0001_20211101]") dsn (LLC_DB)
rename cw1_psex sex
generate source="MCS_COVID_w1"
generate llc_stamp_year=2020
generate llc_stamp_month=5
generate llc_stamp_day=cw1_enddate
drop cw1_enddate
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_COVID_w1", replace
*Covid2
clear
odbc load, exec("select LLC_0001_stud_id, cw2_psex, cw2_enddated, cw2_enddatem FROM [UKSERPUKLLC].[LLC_0001].[MCS_COVID_w2_v0001_20211101]") dsn (LLC_DB)
generate source="MCS_COVID_w2"
generate llc_stamp_year=2020
generate llc_stamp_month=cw2_enddatem
generate llc_stamp_day=cw2_enddated
drop cw2_enddated
drop cw2_enddatem
rename cw2_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_COVID_w2", replace
*Covid3
clear
odbc load, exec("select LLC_0001_stud_id, cw3_psex, cw3_enddatem, cw3_enddated FROM[UKSERPUKLLC].[LLC_0001].[MCS_COVID_w3_v0001_20211101]") dsn (LLC_DB)
generate source="MCS_COVID_w3"
generate llc_stamp_year=2021
generate llc_stamp_month=cw3_enddatem
generate llc_stamp_day=cw3_enddated
drop cw3_enddated
drop cw3_enddatem
rename cw3_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\MCS_COVID_w3", replace
***NCDS58***************************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, ethnic, intdate FROM [UKSERPUKLLC].[LLC_0001].[NCDS58_ncds6_v0001_1_20211101]") dsn (LLC_DB)
generate source="NCDS58_ncds6"
generate llc_stamp_year=mod(intdate, 10000)
generate llc_stamp_month=01
generate llc_stamp_day=01
drop intdate
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NCDS58_ncds6", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw1_psex, cw1_enddate FROM [UKSERPUKLLC].[LLC_0001].[NCDS58_COVID_w1_v0001_20211101]") dsn (LLC_DB)
keep LLC_0001_stud_id cw1_psex cw1_enddate
generate source="NCDS58_COVID_w1"
generate llc_stamp_year=2020
generate llc_stamp_month=5
generate llc_stamp_day=cw1_enddate
drop cw1_enddate
rename cw1_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NCDS58_COVID_w1", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw2_psex, cw2_enddated, cw2_enddatem FROM [UKSERPUKLLC].[LLC_0001].[NCDS58_COVID_w2_v0001_20211101]") dsn (LLC_DB)
generate source="NCDS58_COVID_w2"
generate llc_stamp_year=2020
generate llc_stamp_month=cw2_enddatem
generate llc_stamp_day=cw2_enddated
drop cw2_enddated
drop cw2_enddatem
rename cw2_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NCDS58_COVID_w2", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw3_psex, cw3_enddatem, cw3_enddated FROM [UKSERPUKLLC].[LLC_0001].[NCDS58_COVID_w3_v0001_20211101]") dsn (LLC_DB)
generate source="NCDS58_COVID_w3"
generate llc_stamp_year=2021
generate llc_stamp_month=cw3_enddatem
generate llc_stamp_day=cw3_enddated
drop cw3_enddated
drop cw3_enddatem
rename cw3_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NCDS58_COVID_w3", replace
***NEXTSTEP***************************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, W1ethgrpYP, W8BDATM, W8BDATY FROM [UKSERPUKLLC].[LLC_0001].[NEXTSTEP_basic_demographic_data_v0001_20211101]") dsn (LLC_DB)
generate source="NEXTSTEP_basic_demographic_data"
generate llc_stamp_year=2004
generate llc_stamp_month=01
generate llc_stamp_day=01
rename W1ethgrpYP ethnic
rename W8BDATM mob
rename W8BDATY yob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NEXTSTEP_basic_demographic_data", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw1_psex, cw1_enddate FROM [UKSERPUKLLC].[LLC_0001].[NEXTSTEP_COVID_w1_v0001_20211101]") dsn (LLC_DB)
keep LLC_0001_stud_id cw1_psex cw1_enddate
generate source="NEXTSTEP_COVID_w1"
generate llc_stamp_year=2020
generate llc_stamp_month=5
generate llc_stamp_day=cw1_enddate
drop cw1_enddate
rename cw1_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NEXTSTEP_COVID_w1", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw2_psex, cw2_enddated, cw2_enddatem FROM [UKSERPUKLLC].[LLC_0001].[NEXTSTEP_COVID_w2_v0001_20211101]") dsn (LLC_DB)
generate source="NEXTSTEP_COVID_w2"
generate llc_stamp_year=2020
generate llc_stamp_month=cw2_enddatem
generate llc_stamp_day=cw2_enddated
drop cw2_enddated
drop cw2_enddatem
rename cw2_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NEXTSTEP_COVID_w2", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw3_psex, cw3_enddatem, cw3_enddated FROM [UKSERPUKLLC].[LLC_0001].[NEXTSTEP_COVID_w3_v0001_20211101]") dsn (LLC_DB)
generate source="NEXTSTEP_COVID_w3"
generate llc_stamp_year=2021
generate llc_stamp_month=cw3_enddatem
generate llc_stamp_day=cw3_enddated
drop cw3_enddated
drop cw3_enddatem
rename cw3_psex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NEXTSTEP_COVID_w3", replace
***NICOLA*****************
clear
odbc load, exec("select LLC_0001_stud_id, DN002, DN003, GD002, wave1interviewdate FROM [UKSERPUKLLC].[LLC_0001].[NICOLA_Wave1CAPI_v0001_20211101]") dsn (LLC_DB)
generate source="NICOLA_Wave1CAPI"
generate dob= 01
rename DN002 mob
rename DN003 yob
generate llc_timestamp=dofc(wave1interviewdate)
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
drop wave1interviewdate llc_timestamp
rename GD002 sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NICOLA_Wave1CAPI", replace
***NIHRBIO_COPING******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, Ethnicity, age, sex, gender FROM [UKSERPUKLLC].[LLC_0001].[NIHRBIO_COPING_Bioresource_v0001_20210719]") dsn (LLC_DB)
generate source="NIHRBIO_COPING_Bioresource"
***start data is null .. no date provided ... range is 2018 to 2021
generate llc_stamp_year=2021
generate llc_stamp_month=01
generate llc_stamp_day=01
rename Ethnicity ethnic
generate dos=mdy(llc_stamp_month,llc_stamp_day,llc_stamp_year)
format dos %td
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NIHRBIO_COPING_Bioresource.dta", replace
***NSHD46******************************************************************************************************************************
**Approx 1996-2014
clear
odbc load, exec("select LLC_0001_stud_id, sex FROM [UKSERPUKLLC].[LLC_0001].[NSHD46_SOCIODEMOGRAPHICS_v0001_20211101]") dsn (LLC_DB)
generate source="NSHD46_SOCIODEMOGRAPHICS"
generate llc_stamp_year=2014
generate llc_stamp_month=01
generate llc_stamp_day=01
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NSHD46_SOCIODEMOGRAPHICS.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw1_sext, cw1_covdtmnth, cw1_covdtday FROM [UKSERPUKLLC].[LLC_0001].[NSHD46_COVIDW1WEBPOSTAL_v0001_20211101]") dsn (LLC_DB)
generate source="NSHD46_COVIDW1WEBPOSTAL"
generate llc_stamp_year=2020
generate llc_stamp_month=cw1_covdtmnth
generate llc_stamp_day=cw1_covdtday
replace llc_stamp_day=01 if llc_stamp_day==.
replace llc_stamp_month=01 if llc_stamp_month==.
rename cw1_sext sex
drop cw1_covdtmnth cw1_covdtday
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NSHD46_COVIDW1WEBPOSTAL.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw2_psex, cw2_covdtmnth, cw2_covdtday FROM [UKSERPUKLLC].[LLC_0001].[NSHD46_COVIDW2WEBPOSTAL_v0001_20211101]") dsn (LLC_DB)
generate source="COVIDW2WEBPOSTAL"
generate llc_stamp_year=2020
generate llc_stamp_month=cw2_covdtmnth
generate llc_stamp_day=cw2_covdtday
replace llc_stamp_day=01 if llc_stamp_day==.
replace llc_stamp_month=01 if llc_stamp_month==.
rename cw2_psex sex
drop cw2_covdtmnth cw2_covdtday
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NSHD46_COVIDW2WEBPOSTAL.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, cw3_psex, CW3_ENDDATED, CW3_ENDDATEM FROM [UKSERPUKLLC].[LLC_0001].[NSHD46_COVIDW3WEB_v0001_20211101]") dsn (LLC_DB)
generate source="NSHD46_COVIDW3WEB"
generate llc_stamp_year=2021
generate llc_stamp_month=CW3_ENDDATEM
generate llc_stamp_day=CW3_ENDDATED
replace llc_stamp_day=01 if llc_stamp_day==.
replace llc_stamp_month=01 if llc_stamp_month==.
rename cw3_psex sex
drop CW3_ENDDATED CW3_ENDDATEM
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\NSHD46_COVIDW3WEBPOSTAL.dta", replace
***SABRE******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, sex FROM [UKSERPUKLLC].[LLC_0001].[SABRE_sociodemographic_visit1_v0001_20211101]") dsn (LLC_DB)
generate source="SABRE_sociodemographic_visit1"
generate llc_stamp_year=1990
generate llc_stamp_month=01
generate llc_stamp_day=01
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\SABRE_sociodemographic_visit1.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, sexv3, agev3, ethnicity_srdetail_encv3 FROM [UKSERPUKLLC].[LLC_0001].[SABRE_sociodemographic_visit3_v0001_20211101]") dsn (LLC_DB)
generate source="SABRE_sociodemographic_visit3"
generate llc_stamp_year=2018
generate llc_stamp_month=01
generate llc_stamp_day=01
rename sexv3 sex
rename agev3 age
rename ethnicity_srdetail_encv3 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\SABRE_sociodemographic_visit3.dta", replace
***TRACKC19******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, ethnicity, consented, age, sex FROM [UKSERPUKLLC].[LLC_0001].[TRACKC19_basicInfo_v0001_20210915]") dsn (LLC_DB)
generate source="TRACKC19_basicInfo"
generate llc_timestamp= date(consented, "DMY")
format llc_timestamp %td
generate llc_stamp_year=year(llc_timestamp)
generate llc_stamp_month=month(llc_timestamp)
generate llc_stamp_day=day(llc_timestamp)
drop consented
rename llc_timestamp dos
rename ethnicity ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\TRACKC19_basicInfo.dta", replace
***TWINSUK******************************************************************************************************************************
*Harmonised already from COPE1/joining registry etc.
clear
odbc load, exec("select LLC_0001_stud_id, A1, A2, A4 FROM [UKSERPUKLLC].[LLC_0001].[TWINSUK_DEMOGRAPHICS_v0001_20220531]") dsn (LLC_DB)
generate source="TWINSUK_DEMOGRAPHICS"
generate llc_stamp_year=2020
generate llc_stamp_month=01
generate llc_stamp_day=01
rename A1 sex
rename A2 yob
rename A4 ethnic
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\TWINSUK_DEMOGRAPHICS.dta", replace
***UKHLS******************************************************************************************************************************
clear
odbc load, exec("select LLC_0001_stud_id, j_sex FROM [UKSERPUKLLC].[LLC_0001].[UKHLS_j_indresp_v0003_1_20220531]") dsn (LLC_DB)
generate source="UKHLS_j_indresp"
generate llc_stamp_year=2019
generate llc_stamp_month=01
generate llc_stamp_day=01
rename j_sex sex
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\UKHLS_j_indresp.dta", replace
clear
odbc load, exec("select LLC_0001_stud_id, sex_dv, birthy, racel_dv FROM [UKSERPUKLLC].[LLC_0001].[UKHLS_xsample_v0003_20220531]") dsn (LLC_DB)
generate source="UKHLS_xsample"
generate llc_stamp_year=2021
generate llc_stamp_month=01
generate llc_stamp_day=01
rename sex_dv sex
rename racel_dv ethnic
rename birthy yob
save "S:\LLC_0001\Self-Reported Harmonised Variables\Datasets\Tables\Self-Report Tables\UKHLS_xsample.dta", replace
***FOOTNOTE
*****DATE SPLITTING APART HELP*****
** From this: 2020-03-07 07:45:02.000
*generate temp=word(originalvar,1)
** To this: 2020-03-07
*generate llc_timestamp= date(temp, "YMD")
** To this: 22056 (1960 thing)
**********************************************************
** From this: 21/05/2020 13:20
*generate temp=word(originalvar,1)
** To this: 21/05/2020
*generate llc_timestamp= date(temp, "DMY")
** To this: 22056 (1960 thing)
**********************************************************
**From this: 02jun2010 00:00:00
*generate llc_timestamp=dofc(appt)
** To this: 22056 (1960 thing)
*********************************************************
**Use this to get to readable stata date:
*format llc_timestamp %td
**once in stata date format split apart timestamp into year, month, day
*generate llc_stamp_year=year(llc_timestamp)
*generate llc_stamp_month=month(llc_timestamp)
*generate llc_stamp_day=day(llc_timestamp)