use "D:\S3_Dataset.DTA.dta", clear //Descriptive statistics drop prevalent_TB tabstat Patient_Age, statistics( mean sd median min max iqr ) columns(statistics) tabulate Age tabulate Gender tabulate Stage tabstat BASE_CD4, statistics( mean sd median min max iqr ) columns(statistics) tabulate Base_CD4 gen prevalent_TB=0 replace prevalent_TB=1 if (TB_date-Patient_ARTstartDateWestern)>-240 & (TB_date-Patient_ARTstartDateWestern)<3000 tabulate prevalent_TB tabulate Adherence_2 tabulate Last_status tabulate Age Active, chi2 row tabulate Gender Active, chi2 row tabulate Stage Active, chi2 row tabulate Base_CD4 Active, chi2 row //Immunological failure at first evaluation tabulate Outcome //Immunological failure at first evaluation excluding not evaluated proportion Outcome if Outcome<2 //Immunological failure by type of criteria tab First_failure_type if Outcome==1 //Immunologic failure at last evaluation tab failure_final //Secondline for those with first immunological failure tabulate Secondline if Outcome==1 //tab failure_confirmed //Transition after last immunological evaluation tab failure_confirmed if Outcome==1 //Secondline for those with confirmed immunological failure tabulate Secondline if failure_confirmed==4 //Supporting information Table 1: IMMUNOLOGIC FAILURE STATUS AFTER FOLLOW-UP IMMUNOLOGIC EVALUATION BY IMMUNOLOGIC FAILURE DIGNOSTIC CRITERIA tab First_failure_type failure_confirmed if Outcome==1 & failure_confirmed!=2, row chi2 //Supporting information Table 2: IMMUNOLOGIC FAILURE STATUS AFTER FOLLOW-UP IMMUNOLOGIC EVALUATION BY BASELINE CHRACTERISTICS tab Age failure_confirmed if Outcome==1 & failure_confirmed!=2, row chi2 tab Gender failure_confirmed if Outcome==1 & failure_confirmed!=2, row chi2 tab Stage failure_confirmed if Outcome==1 & failure_confirmed!=2, row chi2 tab Base_CD4 failure_confirmed if Outcome==1 & failure_confirmed!=2, row chi2 //Setting up for survival analysis drop if Outcome==2 stset time, id(Card) failure(Outcome==1) scale(1) //Descriptive survival analysis stdescribe by Outcome, sort : stdescribe //Life table ltable time Outcome, survival //Splitting data by tuberculosis status //generate tbtime=time if TB==0 drop Tuberculosis generate tbtime=(TB_date-Patient_ARTstartDateWestern)/365 if TB==1 & (TB_date-Patient_ARTstartDateWestern)>=180 & (TB_date-Patient_ARTstartDateWestern)<10000 //replace tbtime=time if TB==1 & (TB_date-Patient_ARTstartDateWestern)<=180 stsplit Tuberculosis, at(0) after(_t=tbtime) replace Tuberculosis = Tuberculosis + 1 gen tb=1 if tbtime>0 & tbtime<10 replace Outcome=0 if tb==1 & Outcome==. replace Tuberculosis=0 if Tuberculosis==1 & tbtime==. //Splitting data by treatment interruption status generate losttime=(first_lost-Patient_ARTstartDateWestern)/365 stsplit off_trt, at(0) after(_t=losttime) replace off_trt = off_trt + 1 gen lost=1 if losttime>0 & losttime<10 replace Outcome=0 if lost==1 & Outcome==. replace off_trt=0 if off_trt==1 & losttime==. //Regression analysis drop if Outcome==2 stset time, id(Card) failure(Outcome==1) scale(1) stcox Patient_Age, strata(site) nohr stcox Stage, strata(site) nohr stcox Gender, strata(site) nohr stcox Tuberculosis, strata(site) nohr stcox BASE_CD4, strata(site) nohr stcox off_trt, strata(site) nohr stcox BASE_CD4 Stage, strata(site) nohr estimate store test1 stcox BASE_CD4, strata(site) nohr lrtest . test1 stcox Stage, strata(site) nohr lrtest . test1 stcox BASE_CD4 Stage Gender, strata(site) nohr lrtest . test1 stcox BASE_CD4 Stage Patient_Age, strata(site) nohr lrtest . test1 stcox BASE_CD4 Stage Tuberculosis, strata(site) nohr lrtest . test1 stcox BASE_CD4 Stage off_trt, strata(site) nohr lrtest . test1 //Interaction stcox BASE_CD4 ib(0).Stage c.BASE_CD4#b(0).Stage, strata(site) lrtest . test1 //Preliminary model stcox BASE_CD4 Stage, strata(site) nohr