clear cd c:\chililabdata\data use individual sort individid save, replace use pregnance sort individid merge m:1 individid using individual, keepusing(birthdate) drop if _merge!=3 drop _merge gen socialgpid = substr(sobserveid,1,9) gen round = substr(sobserveid,10,3) replace preg_sdate= preg_sdate/86400000 rename preg_sdate sdate replace preg_edate= preg_edate/86400000 rename preg_edate edate replace birthdate= birthdate/86400000 rename birthdate bod format bod %td format sdate %td format edate %td gen householdkey = socialgpid + round gen individkey = individid+ round drop eventid sobserveid EID fatheridGuid fatherid eobserveid sort individkey /* Recode - Label */ label variable edate "Ngay ket thuc thai san" label variable sdate "Ngay bat dau thai san" label variable individid "Ma ca nhan" label variable embexemdate1 "Kham thai lan 1" label variable embexemdate2 "Kham thai lan 2" label variable embexemdate3 "Kham thai lan 3" label variable embexemdate4 "Kham thai lan 4" label variable embexemdate5 "Kham thai lan 5" label variable embexemdate6 "Kham thai lan 6" label variable embexemdate7 "Kham thai lan 7" label variable embexemdate8 "Kham thai lan 8" label variable embexemdate9 "Kham thai lan 9" label variable preg_inject "So mui tiem chung" label variable preg_etype "Su kien ket thuc thai san" label variable embriodur "Thoi gian mang thai" label variable totallivebirth "So tre sinh song" label variable totalborn "So tre sinh ra" label variable totalchildren "So con con song" label variable EmbrioNo "So lan mang thai" label variable AbortComp "Bien chung" label variable socialgpid "Ma ho " label define tiemchung 1 "Chua tiem mui nao" 2 "Mot mui" 3 "Hai mui" label define sukienketthuc 1 "De thuong hoac can thiep y te" 2 "Thai chet duo 28 tuan tuoi" 3 "Nham" label values preg_inject tiemchung label values preg_etype sukienketthuc save ..\newcode\data\std_pregance, replace