Uloading
Uloading
This commit is contained in:
21
Chililabdata/fertility/gen_householdhead.do
Normal file
21
Chililabdata/fertility/gen_householdhead.do
Normal file
@@ -0,0 +1,21 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use household_head.dta
|
||||
keep if hhd_eobserveid ==""
|
||||
duplicates drop individid, force
|
||||
gen round =substr( hhd_sobserveid,10,3)
|
||||
drop hhd_episodeid hhd_sdate hhd_seventtype hhd_eobserveid hhd_edate hhd_eeventtype hhd_sobserveid
|
||||
gen individkey = individid+round
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_occupation, keepusing(occupationid)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
merge 1:1 individkey using ..\newcode\data\std_education, keepusing(eduid)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
duplicates drop socialgpid, force
|
||||
rename socialgpid householdid
|
||||
sort householdid
|
||||
rename eduid headeduid
|
||||
rename occupationid headoccupationid
|
||||
save ..\fertility\data\householdhead, replace
|
124
Chililabdata/fertility/gen_recidency.do
Normal file
124
Chililabdata/fertility/gen_recidency.do
Normal file
@@ -0,0 +1,124 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use individres.dta
|
||||
gen householdid = substr(res_sobserveid,1,9)
|
||||
gen round = substr(res_sobserveid,10,3)
|
||||
gen individkey = individid + round
|
||||
sort individid res_sobserveid
|
||||
by individid: gen lastrow = _N
|
||||
by individid: gen firstrow= _n
|
||||
gen EnterDate = res_sdate
|
||||
replace EnterDate = EnterDate
|
||||
rename res_seventtype EnterTpe
|
||||
by individid: gen ExitDate = res_edate[lastrow]
|
||||
by individid: gen ExitType = res_eeventtype[lastrow]
|
||||
keep if lastrow == firstrow
|
||||
drop res_episodeid res_sdate res_sobserveid res_eeventtype res_eobserveid res_edate res_sobserveidGuid res_eobserveidGuid lastrow firstrow
|
||||
sort individid
|
||||
merge 1:1 individid using individual
|
||||
drop fatheridGuid motheridGuid individidGuid bornid appround fatherid ethnicid ind_name
|
||||
rename birthdate Bod
|
||||
rename gender Sex
|
||||
keep if _merge == 3
|
||||
drop _merge
|
||||
sort individkey
|
||||
merge 1:1 individkey using standard\std_marstatus, keepusing(marstatusid)
|
||||
keep if _merge == 3
|
||||
drop _merge individkey
|
||||
|
||||
/*format */
|
||||
replace Bod = Bod/86400000
|
||||
format %td Bod
|
||||
replace EnterDate = EnterDate/86400000
|
||||
format EnterDate %td
|
||||
replace ExitDate = ExitDate /86400000
|
||||
format ExitDate %td
|
||||
save ..\fertility\data\recidency, replace
|
||||
|
||||
use standard\std_births
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
merge 1:1 individid using individual, keepusing (bornid)
|
||||
keep if _merge ==3
|
||||
drop bth_place supportper bth_type weight cried socialgpid round locationid gender ethnicid individkey householdkey communeid _merge
|
||||
rename bornid rank
|
||||
save ..\fertility\data\births, replace
|
||||
use relationship.dta, clear
|
||||
drop rel_partneridGuid rel_eobserveid rel_eeventtype rel_edate rel_episodeid
|
||||
rename rel_partnerid partnerid
|
||||
rename rel_sdate MarriageDate
|
||||
replace MarriageDate=MarriageDate/86400000
|
||||
rename rel_seventtype MarriageType
|
||||
rename rel_sobserveid observeid
|
||||
drop if MarriageType == "ENU"
|
||||
gen round = substr(observeid, 10,3)
|
||||
gen householdid = substr(observeid, 1,9)
|
||||
save ..\fertility\data\marriage, replace
|
||||
|
||||
use relationship.dta, clear
|
||||
drop rel_partneridGuid rel_sobserveid rel_seventtype rel_sdate rel_episodeid
|
||||
rename rel_partnerid partnerid
|
||||
rename rel_edate DivorceDate
|
||||
rename rel_eeventtype DivorceType
|
||||
rename rel_eobserveid observeid
|
||||
keep if DivorceType == "DIV" | DivorceType == "SEP"
|
||||
replace DivorceDate=DivorceDate/86400000
|
||||
format DivorceDate %td
|
||||
gen round = substr(observeid, 10,3)
|
||||
gen householdid = substr(observeid, 1,9)
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
save ..\fertility\data\divorce, replace
|
||||
use indmarstatus
|
||||
keep if marstatusid ==2 | marstatusid ==3
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
merge 1:1 individid using individual, keepusing (gender)
|
||||
keep if _merge ==3
|
||||
keep if gender =="2"
|
||||
drop mar_episodeid mar_sobserveid mar_eobserveid gender _merge
|
||||
sort individid
|
||||
merge 1:1 individid using ..\fertility\data\divorce
|
||||
replace DivorceType ="SEP" if marstatusid==2 & DivorceType==""
|
||||
replace DivorceType = "DIV" if marstatusid==3 & DivorceType== ""
|
||||
drop _merge marstatusid
|
||||
save ..\fertility\data\divorce, replace
|
||||
|
||||
/*WDW */
|
||||
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use relationship.dta, clear
|
||||
drop rel_partneridGuid rel_sobserveid rel_seventtype rel_sdate rel_episodeid
|
||||
rename rel_partnerid partnerid
|
||||
rename rel_edate WidowDate
|
||||
rename rel_eeventtype WidowType
|
||||
rename rel_eobserveid observeid
|
||||
keep if WidowType == "WDW"
|
||||
replace WidowDate=WidowDate/86400000
|
||||
format WidowDate %td
|
||||
gen round = substr(observeid, 10,3)
|
||||
gen householdid = substr(observeid, 1,9)
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
save ..\fertility\data\wdw, replace
|
||||
use indmarstatus
|
||||
keep if marstatusid ==4
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
merge 1:1 individid using individual, keepusing (gender)
|
||||
keep if _merge ==3
|
||||
keep if gender =="2"
|
||||
drop mar_episodeid mar_sobserveid mar_eobserveid gender _merge
|
||||
sort individid
|
||||
merge 1:1 individid using ..\fertility\data\wdw
|
||||
replace WidowType ="WDW" if marstatusid==4 & WidowType==""
|
||||
drop _merge marstatusid
|
||||
save ..\fertility\data\wdw, replace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
brow
|
29
Chililabdata/fertility/gen_wdw.do
Normal file
29
Chililabdata/fertility/gen_wdw.do
Normal file
@@ -0,0 +1,29 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use relationship.dta, clear
|
||||
drop rel_partneridGuid rel_sobserveid rel_seventtype rel_sdate rel_episodeid
|
||||
rename rel_partnerid partnerid
|
||||
rename rel_edate WidowDate
|
||||
rename rel_eeventtype WidowType
|
||||
rename rel_eobserveid observeid
|
||||
keep if WidowType == "WDW"
|
||||
replace WidowDate=WidowDate/86400000
|
||||
format WidowDate %td
|
||||
gen round = substr(observeid, 10,3)
|
||||
gen householdid = substr(observeid, 1,9)
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
save ..\fertility\data\wdw, replace
|
||||
use indmarstatus
|
||||
keep if marstatusid ==4
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
merge 1:1 individid using individual, keepusing (gender)
|
||||
keep if _merge ==3
|
||||
keep if gender =="2"
|
||||
drop mar_episodeid mar_sobserveid mar_eobserveid gender _merge
|
||||
sort individid
|
||||
merge 1:1 individid using ..\fertility\data\wdw
|
||||
replace WidowType ="WDW" if marstatusid==4 & WidowType==""
|
||||
drop _merge marstatusid
|
||||
save ..\fertility\data\wdw, replace
|
Reference in New Issue
Block a user