clear cd e:\chililabdata\data use death gen socialgpid = substr(observeid,1,9) replace dth_date=dth_date/86400000 format dth_date %td gen year = year( dth_date) gen h = halfyear(dth_date) gen round = yh(year,h)-89 tostring round, generate(rounds) replace rounds = "0" + rounds if strlen(rounds) ==1 gen socialkey = socialgpid+ rounds gen individkey = individid+ rounds drop EID h eventid observeid year individidGuid duplicates drop individkey, force drop if round < 0 save rDeaths, replace