Uloading
Uloading
This commit is contained in:
77
Chililabdata/newcode/genstd_allbirths.do
Normal file
77
Chililabdata/newcode/genstd_allbirths.do
Normal file
@@ -0,0 +1,77 @@
|
||||
clear all
|
||||
cd c:\chililabdata\newcode\data
|
||||
use std_births
|
||||
gen year = year(bod)
|
||||
tostring year, replace
|
||||
sort individid
|
||||
drop individkey
|
||||
rename individid childid
|
||||
rename bornid childbornid
|
||||
|
||||
|
||||
|
||||
gen individkey = motherid + round
|
||||
sort individkey
|
||||
merge m:1 individkey using std_education, keepusing(eduid)
|
||||
keep if _merge !=2
|
||||
rename eduid meduid
|
||||
drop _merge
|
||||
|
||||
merge m:1 individkey using std_occupation, keepusing(occupationid)
|
||||
keep if _merge !=2
|
||||
rename occupationid moccupationid
|
||||
drop _merge
|
||||
|
||||
replace individkey = fatherid + round
|
||||
sort individkey
|
||||
merge m:1 individkey using std_education, keepusing(eduid)
|
||||
keep if _merge !=2
|
||||
rename eduid feduid
|
||||
drop _merge
|
||||
|
||||
merge m:1 individkey using std_occupation,keepusing(occupationid)
|
||||
keep if _merge !=2
|
||||
rename occupationid foccupationid
|
||||
drop _merge
|
||||
drop individkey
|
||||
rename motherid individid
|
||||
sort individid
|
||||
merge m:1 individid using std_individual , keepusing(birthdate bornid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
rename birthdate mbod
|
||||
rename bornid mbornid
|
||||
rename individid motherid
|
||||
|
||||
rename fatherid individid
|
||||
sort individid
|
||||
merge m:1 individid using std_individual , keepusing(birthdate bornid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
rename birthdate fbod
|
||||
rename bornid fbornid
|
||||
rename individid fatherid
|
||||
rename childid individid
|
||||
drop motheridGuid fatheridGuid appround
|
||||
replace householdkey = socialgpid + year
|
||||
merge m:1 householdkey using houseinfo, keepusing (quintile)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort individid
|
||||
save std_allbirths, replace
|
||||
|
||||
use std_individual
|
||||
keep if length(motherid)==11
|
||||
sort motherid birthdate
|
||||
|
||||
gen prevchildid = individid[_n-1] if mother[_n-1] ==motherid
|
||||
gen prevgender = sex[_n-1] if mother[_n-1] ==motherid
|
||||
gen prevbirthdate = birthdate[_n-1] if mother[_n-1] ==motherid
|
||||
sort individid
|
||||
save tmp_individual, replace
|
||||
use std_allbirths
|
||||
merge 1:1 individid using tmp_individual, keepusing(prevchildid prevgender prevbirthdate)
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
cd c:\chililabdata\newcode
|
||||
Reference in New Issue
Block a user