Dear Dr Nandi,
I do have a short follow up question before you close this one. In the cild file I have 90,000 obs. I end up with only 60,000 matches when I merge the files.
I cannot see why I would have such a large number of mismatches. If you have any ideas, I would appreciate a short comment.
Thanks a lot!
Nico
Result # of obs.
-----------------------------------------
not matched 289,433
from master 259,370 (_wemerge==1)
from using 30,063 (_wemerge==2)
matched 60,664 (_wemerge==3)
-----------------------------------------
global Stata11_se "F:\UnderstandingSocietyData\Data\stata\stata11_se"
global data "P:\Mergeddata_master2016_religion"
global dofiles "P:\Dofiles_master2016_religion"
global logfiles "P:\Logfiles_master2016_religion"
foreach w in a b c d e f{
use `w'_ukborn pidp fpid mpid `w'_hidp `w'_pno `w'_istrtdaty `w'_plbornc `w'_jbhrs `w'_qfhigh `w'_qualoc `w'_sex `w'_dvage `w'_marstat `w'_fimngrs_dv `w'_fimnlabgrs_dv `w'_jbstat `w'_plbornc_all `w'_pacob_all `w'_macob_all ///
`w'_oprlg1 `w'_oprlg0 ///
`w'_paygu_dv `w'_oprlg `w'_yr2uk4 `w'_birthy `w'_feend `w'_scend `w'_jbterm1 `w'_jbsize `w'_jbsect `w'_jbsectpub `w'_racel `w'_jbbgy `w'_sf1 `w'_jbmngr `w'_lnprnt `w'_jbsemp ///
`w'_gor_dv `w'_urban_dv `w'_jshrs ///
using "$Stata11_se/`w'_indresp_protect", clear
gen wave = strpos("abcdef","`w'")
renpfix `w'_
save $data/`w'wave, replace
}
foreach w in a b c d e {
append using $data/`w'wave.dta
}
sort wave pidp
rename pidp PIDP
rename dvage age
save $data/abcdef_long, replace
foreach w in a b c d e f{
erase $data/`w'wave.dta
}
foreach w in a b c d e f{
use pidp `w'_hidp `w'_sex `w'_dvage `w'_hgbiom `w'_hgbiof `w'_adresp15 `w'_birthy `w'_birthm fpid mpid `w'_fnpno `w'_fnspid `w'_mnpno `w'_mnspid ///
using "$Stata11_se/`w'_child_protect", clear
gen wave = strpos("abcdef","`w'")
renpfix `w'_
save $data/`w'wave, replace
}
foreach w in a b c d e {
append using $data/`w'wave.dta
}
sort wave pidp
rename fnspid PIDP
rename dvage childage
rename sex childgender
save $data/abcdef_long_2, replace
foreach w in a b c d e f{
erase $data/`w'wave.dta
}
use $data/abcdef_long, clear
merge 1:m PIDP wave using $data/abcdef_long_2, generate (_wemerge)