*! version 3.1.0 02/08/94 (STB-19: ssa3) program define asurvcrv version 3.0 local options /* */ "WIth(string) BY(string)" local varlist "req ex min(2) max(2)" local if "opt" local in "opt" local weight "iweight aweight fweight" parse "`*'" parse "`varlist'", parse(" ") local time "`1'" local died "`2'" tempvar ratio dd if ("`died'"=="") { tempvar dd local died `dd' gen byte `dd' = 1 } qui tab(`by') , gen(__g) qui cox `time' `with' __g* `if' `in' [`weight'`exp'], dead(`died') drop __g* parse "`with'", parse(" ") qui gen `ratio' = 1 while ("`1'"!="") { qui summ `1' [`weight'`exp'] qui replace `ratio' = `ratio'/exp(_b[`1']*(`1'-_result(3))) mac shift } _wsrvcrv `time' `died' `if' `in' [iw=`ratio'], by(`by') end