39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
clear all
|
|
set mem 200M
|
|
cd e:\chililabdata\data
|
|
use individual
|
|
sort individid
|
|
save individual, replace
|
|
use observation
|
|
sort observeid
|
|
save observation, replace
|
|
use birth
|
|
gen year = year(bth_date)
|
|
drop if year != $year
|
|
sort observeid
|
|
merge observeid using observation
|
|
|
|
gen communeid = substr(locationid, 1,2)
|
|
replace communeid = "00" if $communeid==0
|
|
drop if communeid ! ="0$communeid"
|
|
drop if _merge !=3
|
|
keep individid communeid year bth_date
|
|
sort individid
|
|
|
|
merge individid using individual
|
|
drop if _merge !=3
|
|
rename individid childid
|
|
rename motherid individid
|
|
keep communeid individid year bth_date
|
|
sort individid
|
|
|
|
merge individid using individual
|
|
drop if _merge != 3
|
|
gen age = floor((bth_date-birthdate)/365.5)
|
|
drop if age < 15 | age > 49
|
|
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)
|
|
sort communeid agegrp
|
|
collapse (count) births = year , by (communeid agegrp)
|
|
sort agegrp
|
|
save Birth\WomenBirthYear, replace
|
|
cd e:\chililabdata |