---------------------------------------------------------------------------------------------------------------------------------------------------------- name: log: D:\Home\anandi\UKHLS\UKHLS - 4 Data Management and Access\UKHLS - UserForum\logfiles/UserForum_1370.log log type: text opened on: 26 Jun 2020, 00:58:34 . . // assign global macro to refer to Understanding Society data . global ukhls "D:\Home\anandi\DATA\UKHLS\main\eul" . . // assign global macros for the lists of waves . global BHPSwaves "a b c d e f g h i j k l m n o p q r" . global UKHLSwaves_bh "b c d e f g h i" // since BHPS respondents did not take . // part in Wave 1, begin at Wave 2 . // - update this to include . // new waves as they are released . global UKHLSno 9 // number of waves of UKHLS data . . // loop through the waves of bhps . foreach w of global BHPSwaves { 2. . // find the wave number . local waveno=strpos("abcdefghijklmnopqrstuvwxyz","`w'") 3. . // open the individual file for that wave . use pidp b`w'_age_dv b`w'_paygu_dv using /// > "$ukhls/bhps_w`waveno'/b`w'_indresp", clear 4. . // remove the wave prefix . rename b`w'_* * 5. . // generate a variable which records the wave number . gen wave=`waveno' 6. . // save the file for future use . save tmp_b`w'_indresp, replace 7. } (note: file tmp_ba_indresp.dta not found) file tmp_ba_indresp.dta saved (note: file tmp_bb_indresp.dta not found) file tmp_bb_indresp.dta saved (note: file tmp_bc_indresp.dta not found) file tmp_bc_indresp.dta saved (note: file tmp_bd_indresp.dta not found) file tmp_bd_indresp.dta saved (note: file tmp_be_indresp.dta not found) file tmp_be_indresp.dta saved (note: file tmp_bf_indresp.dta not found) file tmp_bf_indresp.dta saved (note: file tmp_bg_indresp.dta not found) file tmp_bg_indresp.dta saved (note: file tmp_bh_indresp.dta not found) file tmp_bh_indresp.dta saved (note: file tmp_bi_indresp.dta not found) file tmp_bi_indresp.dta saved (note: file tmp_bj_indresp.dta not found) file tmp_bj_indresp.dta saved (note: file tmp_bk_indresp.dta not found) file tmp_bk_indresp.dta saved (note: file tmp_bl_indresp.dta not found) file tmp_bl_indresp.dta saved (note: file tmp_bm_indresp.dta not found) file tmp_bm_indresp.dta saved (note: file tmp_bn_indresp.dta not found) file tmp_bn_indresp.dta saved (note: file tmp_bo_indresp.dta not found) file tmp_bo_indresp.dta saved (note: file tmp_bp_indresp.dta not found) file tmp_bp_indresp.dta saved (note: file tmp_bq_indresp.dta not found) file tmp_bq_indresp.dta saved (note: file tmp_br_indresp.dta not found) file tmp_br_indresp.dta saved . . // loop through the relevant waves of Understanding Society . foreach w of global UKHLSwaves_bh { 2. . // find the wave number . local waveno=strpos("abcdefghijklmnopqrstuvwxyz","`w'") 3. . // open the individual level file for that wave . use pidp pid `w'_age_dv `w'_paygu_dv using /// > "$ukhls/ukhls_w`waveno'/`w'_indresp", clear 4. . // keep the individual if they have a pid - ie were part of BHPS . // individuals have pid==-8 (inapplicable) if they were not part of BHPS . keep if pid>0 5. . // drop the pid variable . drop pid 6. . // remove the wave prefix . rename `w'_* * 7. . // generate a variable which records the wave number + 17 . // - treating wave 2 ukhls as wave 19 of bhps . gen wave=`waveno'+17 8. . // save the file for future use . save tmp_`w'_indresp, replace 9. } (Substantive data for responding adults (16+), incl. proxies) (42,791 observations deleted) (note: file tmp_b_indresp.dta not found) file tmp_b_indresp.dta saved ( ) (38,727 observations deleted) (note: file tmp_c_indresp.dta not found) file tmp_c_indresp.dta saved ( ) (36,983 observations deleted) (note: file tmp_d_indresp.dta not found) file tmp_d_indresp.dta saved ( ) (35,288 observations deleted) (note: file tmp_e_indresp.dta not found) file tmp_e_indresp.dta saved ( ) (36,319 observations deleted) (note: file tmp_f_indresp.dta not found) file tmp_f_indresp.dta saved ( ) (33,670 observations deleted) (note: file tmp_g_indresp.dta not found) file tmp_g_indresp.dta saved ( ) (31,212 observations deleted) (note: file tmp_h_indresp.dta not found) file tmp_h_indresp.dta saved ( ) (28,440 observations deleted) (note: file tmp_i_indresp.dta not found) file tmp_i_indresp.dta saved . . // loop through the waves of bhps . foreach w of global BHPSwaves { 2. . // first time through the loop . if "`w'"=="a" { 3. . // reopen the first file created . use tmp_ba_indresp, clear 4. . // following times through the loop . } 5. else { 6. . // append each file in turn . append using tmp_b`w'_indresp 7. } 8. } (note: variable age_dv was byte, now int to accommodate using data's values) . . // loop through the waves of ukhls from Wave 2 . foreach w of global UKHLSwaves_bh { 2. . // append each file in turn . append using tmp_`w'_indresp 3. } . . // create labels for the wave variable . // loop through the waves of bhps . foreach n of numlist 1/18 { 2. . // add a label for each wave number in turn . lab def wave `n' "BHPS Wave `n'", modify 3. } . . // loop through the waves of ukhls . // (using the global macro UKHLSno to define the last wave) . foreach n of numlist 2/$UKHLSno { 2. . // calculate which label value this label will apply to . local waveref=`n'+17 3. . // add a label for each wave in turn . lab def wave `waveref' "UKHLS Wave `n'", modify 4. } . . // apply the label to the wave variable . lab val wave wave . . // check how many observations are available from each wave . tab wave wave | Freq. Percent Cum. -------------+----------------------------------- BHPS Wave 1 | 10,264 3.26 3.26 BHPS Wave 2 | 9,845 3.13 6.40 BHPS Wave 3 | 9,600 3.05 9.45 BHPS Wave 4 | 9,481 3.02 12.46 BHPS Wave 5 | 9,249 2.94 15.41 BHPS Wave 6 | 9,438 3.00 18.41 BHPS Wave 7 | 11,193 3.56 21.97 BHPS Wave 8 | 10,906 3.47 25.43 BHPS Wave 9 | 15,623 4.97 30.40 BHPS Wave 10 | 15,603 4.96 35.37 BHPS Wave 11 | 18,867 6.00 41.37 BHPS Wave 12 | 16,597 5.28 46.64 BHPS Wave 13 | 16,238 5.16 51.81 BHPS Wave 14 | 15,791 5.02 56.83 BHPS Wave 15 | 15,617 4.97 61.80 BHPS Wave 16 | 15,392 4.90 66.69 BHPS Wave 17 | 14,873 4.73 71.42 BHPS Wave 18 | 14,419 4.59 76.01 UKHLS Wave 2 | 11,778 3.75 79.75 UKHLS Wave 3 | 10,965 3.49 83.24 UKHLS Wave 4 | 10,088 3.21 86.45 UKHLS Wave 5 | 9,545 3.04 89.48 UKHLS Wave 6 | 8,869 2.82 92.31 UKHLS Wave 7 | 8,498 2.70 95.01 UKHLS Wave 8 | 8,081 2.57 97.58 UKHLS Wave 9 | 7,615 2.42 100.00 -------------+----------------------------------- Total | 314,435 100.00 . . // check that each row is uniquely identified by pidp wave . // if that is not the case, this will give an error message and . // syntax will stop running . isid pidp wave . . // save the file containing all waves . save all_indresp, replace file all_indresp.dta saved . . // erase each temporary file using loops . foreach w of global BHPSwaves { 2. erase tmp_b`w'_indresp.dta 3. } . foreach w of global UKHLSwaves_bh { 2. erase tmp_`w'_indresp.dta 3. } . . log close name: log: D:\Home\anandi\UKHLS\UKHLS - 4 Data Management and Access\UKHLS - UserForum\logfiles/UserForum_1370.log log type: text closed on: 26 Jun 2020, 00:58:37 ----------------------------------------------------------------------------------------------------------------------------------------------------------