Files
Dss/Chililabdata/newcode/genstd_relationship.do
admin 8c43da1d1c Uloading
Uloading
2025-08-02 05:26:16 +07:00

58 lines
1.4 KiB
Plaintext

clear all
cd c:\chililabdata\data
use relationship
drop if individid == "" | individid == "0"
save female_relationship, replace
use relationship
rename individid individid1
rename rel_partnerid individid
rename individid1 rel_partnerid
drop if individid == "" | individid == "0"
save male_relationship, replace
use female_relationship
append using male_relationship
drop if length(individid) != 11
drop rel_partneridGuid rel_episodeid
rename rel_partnerid partnerid
rename rel_sdate marriagedate
rename rel_edate marriageedate
rename rel_seventtype marriagetype
rename rel_eeventtype eeventtype
rename rel_sobserveid sobserveid
rename rel_eobserveid eobserveid
gen sround = substr(sobserveid, 10,3)
destring sround, replace
gen eround ="023" if eobserveid==""
replace eround = substr(eobserveid, 10,3) if eobserveid !=""
destring(eround), replace
duplicates drop individid sobserveid,force
duplicates drop individid eround,force
gen period = eround - sround
expand period
sort individid partnerid sround
by individid partnerid sround: gen step=_n-1
gen round = sround + step
duplicates drop individid round, force
drop if round >=23
tostring round, replace
replace round = "00" + round if strlen(round) == 1
replace round = "0" + round if strlen(round) == 2
gen individkey = individid + round
sort individkey
drop sobserveid eeventtype eobserveid sround eround period step round marriageedate
save ..\newcode\data\std_relationship, replace