99 lines
2.8 KiB
Plaintext
99 lines
2.8 KiB
Plaintext
cd e:\chililabdata
|
|
clear all
|
|
global startTime = mdy(12,31,2003)
|
|
global endTime = mdy(12,31,2010)
|
|
set mem 200M
|
|
do pdo1
|
|
global refdate = $endTime
|
|
do ..\GenCrossEducation
|
|
do ..\GenCrossOccupation
|
|
do ..\GenMaritalstatus
|
|
use individual, clear
|
|
sort individid
|
|
save, replace
|
|
use location
|
|
sort locationid
|
|
save, replace
|
|
use observation
|
|
sort observeid
|
|
save observation, replace
|
|
use death
|
|
drop if dth_date < $startTime
|
|
drop if dth_date > $endTime
|
|
sort individid
|
|
merge individid using individual, nokeep keep (birthdate gender motherid fatherid )
|
|
rename birthdate bod
|
|
drop if _merge !=3
|
|
drop _merge
|
|
replace fatherid = "00000000000" if strlen(fatherid) !=11
|
|
replace motherid = "00000000000" if strlen(motherid) !=11
|
|
gen age = (dth_date - bod)/365.25
|
|
replace age = floor(age)
|
|
sort observeid
|
|
merge observeid using observation
|
|
drop if _merge!=3
|
|
drop _merge
|
|
gen communeid = substr(locationid, 1,2)
|
|
sort communeid
|
|
gen area=1
|
|
replace area=2 if (communeid=="02")
|
|
replace area=2 if (communeid=="04")
|
|
replace area=2 if (communeid=="05")
|
|
replace area=2 if (communeid=="07")
|
|
sort locationid
|
|
merge locationid using location,nokeep keep (address)
|
|
drop _merge
|
|
sort individid
|
|
gen refquarter = qofd(dth_date)
|
|
tostring refquarter, generate (qkey)
|
|
gen key = individid + qkey
|
|
sort key
|
|
merge key using crosseducationtemp, nokeep keep(eduid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
sort key
|
|
merge key using crossoccupationtemp, nokeep keep(occupationid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
sort key
|
|
merge key using crossmarstatustemp, nokeep keep (marstatusid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
|
|
replace key = fatherid + qkey
|
|
sort key
|
|
merge key using crosseducationtemp, nokeep keep(feduid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
sort key
|
|
merge key using crossoccupationtemp, nokeep keep (foccupationid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
|
|
replace key = motherid + qkey
|
|
sort key
|
|
merge key using crosseducationtemp, nokeep keep(meduid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
sort key
|
|
merge key using crossoccupationtemp, nokeep keep(moccupationid)
|
|
drop if _merge==2
|
|
drop _merge
|
|
save $savefolder\alldeath$suffix, replace
|
|
gen MDeaths =0
|
|
gen FDeaths =0
|
|
replace MDeaths =1 if gender =="1"
|
|
replace FDeaths =1 if gender =="2"
|
|
collapse (sum) MDeaths FDeaths, by(communeid age )
|
|
save $savefolder\deathby_commune_age$suffix, replace
|
|
recode age (min/0=1 "<1") (1/4=2 "1-4") (5/9=3 "5-9")(10/14=4 "10-14") (15/19=5 "15-19") (20/24=6 "20-24") (25/29=7 "25-29") (30/34=8 "30-34") (35/39=9 "35-39") (40/44=10 "40-44") (45/49=11 "45-49")(50/54=12 "50-54") (55/59=13 "55-59") (60/64=14 "60-64") (65/69=15 "65-69") (70/74=16 "70-74") (75/79=17 "75-79") (80/max=18 ">=80") , gen (agegrp)
|
|
collapse (sum) MDeaths FDeaths, by(communeid agegrp )
|
|
save $savefolder\deathby_commune_agegrp$suffix, replace
|
|
|
|
collapse (sum) MDeaths FDeaths, by(agegrp )
|
|
save $savefolder\deathby_agegrp$suffix, replace
|
|
|
|
|
|
|
|
cd e:\chililabdata
|