Files
Dss/Chililabdata/GenAllBirth.do
admin 8c43da1d1c Uloading
Uloading
2025-08-02 05:26:16 +07:00

109 lines
2.5 KiB
Plaintext

clear all
set mem 1000M
cd c:\chililabdata\data
use individual
sort individid
save individual, replace
use observation
sort observeid
save observation, replace
use birth
gen year = year(bth_date)
sort observeid
merge observeid using observation
gen communeid = substr(locationid, 1,2)
drop if _merge !=3
drop _merge
sort individid
merge individid using individual
drop if _merge !=3
drop _merge
gen quarterdate = qofd(bth_date)
tostring quarterdate, gen(quarter)
drop fatheridGuid motheridGuid socialgpidGuid observeidGuid obs_field_wrkr obs_data_clerk obs_responsor appround eventid individidGuid observeid obs_round obs_entry_date obs_de_date obs_status_dat quarterdate
rename bornid childbornid
gen key = motherid + quarter
sort key
save birth/allbirths, replace
keep key
sort key
merge key using crosseducationtemp, keep(meduid)
keep if _merge !=2
drop _merge
sort key
merge key using birth/allbirths
drop _merge
replace key = fatherid + quarter
sort key
save birth/allbirths, replace
keep key
sort key
merge key using crosseducationtemp, keep(feduid)
keep if _merge !=2
drop _merge
sort key
merge key using birth/allbirths
drop _merge
replace key = motherid + quarter
sort key
save birth\allbirths, replace
keep key
sort key
merge key using crossoccupationtemp, keep(moccupationid)
keep if _merge !=2
drop _merge
sort key
merge key using birth/allbirths
drop _merge
replace key = fatherid + quarter
sort key
save birth\allbirths, replace
keep key
sort key
merge key using crossoccupationtemp, keep(foccupationid)
keep if _merge !=2
drop _merge
sort key
merge key using birth/allbirths
drop _merge
replace key = socialgpid + quarter
sort key
save birth/allbirths, replace
keep key
sort key
merge key using householdinfortemp
keep if _merge !=2
drop _merge
sort key
merge key using birth/allbirths
drop _merge
sort key
drop birthdate
rename individid childid
rename fatherid individid
sort individid
merge individid using individual, keep(birthdate bornid)
keep if _merge !=2
rename birthdate fbirthdate
rename bornid fbornid
rename individid fatherid
rename motherid individid
drop _merge
sort individid
merge individid using individual, keep(birthdate bornid)
keep if _merge !=2
rename birthdate mbirthdate
rename bornid mbornid
rename individid motherid
rename childid individid
drop key hhinforid observeid responsorID entryDate fieldWrkr dataClerk deDate statusDat obs_de_date refdate period p quarterdate refquarter maxobs_de_date quarter _merge
save birth/allbirths, replace
cd c:\chililabdata