Project

General

Profile

Support #1370 » UserForum_1370.log

Alita Nandi, 06/26/2020 01:02 AM

 
1
----------------------------------------------------------------------------------------------------------------------------------------------------------
2
      name:  <unnamed>
3
       log:  D:\Home\anandi\UKHLS\UKHLS - 4 Data Management and Access\UKHLS - UserForum\logfiles/UserForum_1370.log
4
  log type:  text
5
 opened on:  26 Jun 2020, 00:58:34
6

    
7
. 
8
. // assign global macro to refer to Understanding Society data
9
. global ukhls "D:\Home\anandi\DATA\UKHLS\main\eul"
10

    
11
. 
12
. // assign global macros for the lists of waves
13
. global BHPSwaves "a b c d e f g h i j k l m n o p q r"
14

    
15
. global UKHLSwaves_bh "b c d e f g h i" // since BHPS respondents did not take 
16

    
17
.                                                                          // part in Wave 1, begin at Wave 2
18
.                                                                          // - update this to include 
19
.                                                                          // new waves as they are released
20
. global UKHLSno 9        // number of waves of UKHLS data                                                                 
21

    
22
. 
23
. // loop through the waves of bhps
24
. foreach w of global BHPSwaves {
25
  2. 
26
.         // find the wave number
27
.         local waveno=strpos("abcdefghijklmnopqrstuvwxyz","`w'")
28
  3. 
29
.         // open the individual file for that wave
30
.         use pidp b`w'_age_dv b`w'_paygu_dv using ///
31
>         "$ukhls/bhps_w`waveno'/b`w'_indresp", clear
32
  4.         
33
.         // remove the wave prefix
34
.         rename b`w'_* *
35
  5.         
36
.         // generate a variable which records the wave number
37
.         gen wave=`waveno'
38
  6.         
39
.         // save the file for future use
40
.         save tmp_b`w'_indresp, replace
41
  7. }
42
(note: file tmp_ba_indresp.dta not found)
43
file tmp_ba_indresp.dta saved
44
(note: file tmp_bb_indresp.dta not found)
45
file tmp_bb_indresp.dta saved
46
(note: file tmp_bc_indresp.dta not found)
47
file tmp_bc_indresp.dta saved
48
(note: file tmp_bd_indresp.dta not found)
49
file tmp_bd_indresp.dta saved
50
(note: file tmp_be_indresp.dta not found)
51
file tmp_be_indresp.dta saved
52
(note: file tmp_bf_indresp.dta not found)
53
file tmp_bf_indresp.dta saved
54
(note: file tmp_bg_indresp.dta not found)
55
file tmp_bg_indresp.dta saved
56
(note: file tmp_bh_indresp.dta not found)
57
file tmp_bh_indresp.dta saved
58
(note: file tmp_bi_indresp.dta not found)
59
file tmp_bi_indresp.dta saved
60
(note: file tmp_bj_indresp.dta not found)
61
file tmp_bj_indresp.dta saved
62
(note: file tmp_bk_indresp.dta not found)
63
file tmp_bk_indresp.dta saved
64
(note: file tmp_bl_indresp.dta not found)
65
file tmp_bl_indresp.dta saved
66
(note: file tmp_bm_indresp.dta not found)
67
file tmp_bm_indresp.dta saved
68
(note: file tmp_bn_indresp.dta not found)
69
file tmp_bn_indresp.dta saved
70
(note: file tmp_bo_indresp.dta not found)
71
file tmp_bo_indresp.dta saved
72
(note: file tmp_bp_indresp.dta not found)
73
file tmp_bp_indresp.dta saved
74
(note: file tmp_bq_indresp.dta not found)
75
file tmp_bq_indresp.dta saved
76
(note: file tmp_br_indresp.dta not found)
77
file tmp_br_indresp.dta saved
78

    
79
. 
80
. // loop through the relevant waves of Understanding Society
81
. foreach w of global UKHLSwaves_bh {
82
  2. 
83
.         // find the wave number
84
.         local waveno=strpos("abcdefghijklmnopqrstuvwxyz","`w'")
85
  3.         
86
.         // open the individual level file for that wave
87
.         use pidp pid `w'_age_dv `w'_paygu_dv using ///
88
>         "$ukhls/ukhls_w`waveno'/`w'_indresp", clear
89
  4.         
90
.         // keep the individual if they have a pid - ie were part of BHPS
91
.         // individuals have pid==-8 (inapplicable) if they were not part of BHPS
92
.         keep if pid>0
93
  5.         
94
.         // drop the pid variable
95
.         drop pid
96
  6.         
97
.         // remove the wave prefix
98
.         rename `w'_* *
99
  7. 
100
.         // generate a variable which records the wave number + 17 
101
.         // - treating wave 2 ukhls as wave 19 of bhps
102
.         gen wave=`waveno'+17
103
  8.         
104
.         // save the file for future use
105
.         save tmp_`w'_indresp, replace
106
  9. }
107
(Substantive data for responding adults (16+), incl. proxies)
108
(42,791 observations deleted)
109
(note: file tmp_b_indresp.dta not found)
110
file tmp_b_indresp.dta saved
111
( )
112
(38,727 observations deleted)
113
(note: file tmp_c_indresp.dta not found)
114
file tmp_c_indresp.dta saved
115
( )
116
(36,983 observations deleted)
117
(note: file tmp_d_indresp.dta not found)
118
file tmp_d_indresp.dta saved
119
( )
120
(35,288 observations deleted)
121
(note: file tmp_e_indresp.dta not found)
122
file tmp_e_indresp.dta saved
123
( )
124
(36,319 observations deleted)
125
(note: file tmp_f_indresp.dta not found)
126
file tmp_f_indresp.dta saved
127
( )
128
(33,670 observations deleted)
129
(note: file tmp_g_indresp.dta not found)
130
file tmp_g_indresp.dta saved
131
( )
132
(31,212 observations deleted)
133
(note: file tmp_h_indresp.dta not found)
134
file tmp_h_indresp.dta saved
135
( )
136
(28,440 observations deleted)
137
(note: file tmp_i_indresp.dta not found)
138
file tmp_i_indresp.dta saved
139

    
140
. 
141
. // loop through the waves of bhps
142
. foreach w of global BHPSwaves {
143
  2.         
144
.         // first time through the loop
145
.         if "`w'"=="a" {
146
  3.         
147
.                 // reopen the first file created
148
.                 use tmp_ba_indresp, clear
149
  4.                 
150
.         // following times through the loop     
151
.         } 
152
  5.         else {  
153
  6.                 
154
.                 // append each file in turn
155
.                 append using tmp_b`w'_indresp
156
  7.         }
157
  8. }
158
(note: variable age_dv was byte, now int to accommodate using data's values)
159

    
160
. 
161
. // loop through the waves of ukhls from Wave 2
162
. foreach w of global UKHLSwaves_bh {
163
  2.         
164
.         // append each file in turn
165
.         append using tmp_`w'_indresp
166
  3. }
167

    
168
. 
169
. // create labels for the wave variable
170
. // loop through the waves of bhps
171
. foreach n of numlist 1/18 {
172
  2. 
173
.         // add a label for each wave number in turn
174
.         lab def wave `n' "BHPS Wave `n'", modify
175
  3. }
176

    
177
. 
178
. // loop through the waves of ukhls 
179
. // (using the global macro UKHLSno to define the last wave)
180
. foreach n of numlist 2/$UKHLSno {
181
  2.         
182
.         // calculate which label value this label will apply to
183
.         local waveref=`n'+17
184
  3.         
185
.         // add a label for each wave in turn
186
.         lab def wave `waveref' "UKHLS Wave `n'", modify
187
  4. }
188

    
189
. 
190
. // apply the label to the wave variable
191
. lab val wave wave
192

    
193
. 
194
. // check how many observations are available from each wave
195
. tab wave
196

    
197
        wave |      Freq.     Percent        Cum.
198
-------------+-----------------------------------
199
 BHPS Wave 1 |     10,264        3.26        3.26
200
 BHPS Wave 2 |      9,845        3.13        6.40
201
 BHPS Wave 3 |      9,600        3.05        9.45
202
 BHPS Wave 4 |      9,481        3.02       12.46
203
 BHPS Wave 5 |      9,249        2.94       15.41
204
 BHPS Wave 6 |      9,438        3.00       18.41
205
 BHPS Wave 7 |     11,193        3.56       21.97
206
 BHPS Wave 8 |     10,906        3.47       25.43
207
 BHPS Wave 9 |     15,623        4.97       30.40
208
BHPS Wave 10 |     15,603        4.96       35.37
209
BHPS Wave 11 |     18,867        6.00       41.37
210
BHPS Wave 12 |     16,597        5.28       46.64
211
BHPS Wave 13 |     16,238        5.16       51.81
212
BHPS Wave 14 |     15,791        5.02       56.83
213
BHPS Wave 15 |     15,617        4.97       61.80
214
BHPS Wave 16 |     15,392        4.90       66.69
215
BHPS Wave 17 |     14,873        4.73       71.42
216
BHPS Wave 18 |     14,419        4.59       76.01
217
UKHLS Wave 2 |     11,778        3.75       79.75
218
UKHLS Wave 3 |     10,965        3.49       83.24
219
UKHLS Wave 4 |     10,088        3.21       86.45
220
UKHLS Wave 5 |      9,545        3.04       89.48
221
UKHLS Wave 6 |      8,869        2.82       92.31
222
UKHLS Wave 7 |      8,498        2.70       95.01
223
UKHLS Wave 8 |      8,081        2.57       97.58
224
UKHLS Wave 9 |      7,615        2.42      100.00
225
-------------+-----------------------------------
226
       Total |    314,435      100.00
227

    
228
. 
229
. // check that each row is uniquely identified by pidp wave
230
. // if that is not the case, this will give an error message and
231
. // syntax will stop running
232
. isid pidp wave
233

    
234
. 
235
. // save the file containing all waves
236
. save all_indresp, replace
237
file all_indresp.dta saved
238

    
239
. 
240
. // erase each temporary file using loops
241
. foreach w of global BHPSwaves {
242
  2.         erase tmp_b`w'_indresp.dta
243
  3. }
244

    
245
. foreach w of global UKHLSwaves_bh {
246
  2.         erase tmp_`w'_indresp.dta
247
  3. }
248

    
249
. 
250
. log close
251
      name:  <unnamed>
252
       log:  D:\Home\anandi\UKHLS\UKHLS - 4 Data Management and Access\UKHLS - UserForum\logfiles/UserForum_1370.log
253
  log type:  text
254
 closed on:  26 Jun 2020, 00:58:37
255
----------------------------------------------------------------------------------------------------------------------------------------------------------
(3-3/3)