30 lines
940 B
Plaintext
30 lines
940 B
Plaintext
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
|