* Created: March 9 2004 Last modified: March 9 2004; * RATIO_CONFIDENCE_INTERVALS: Using bootstrap replicates, calculate confidence intervals; * for Q1/Q5 ratios, amb. visit to hospitalization ratios, and Q1/Q5 ratios for the V/H; * ratios; libname acs '/dsd1/walld/acs'; proc format; value acsl 1='1.Cong.syphillis ' 2='2.Immune rel./prev. ' 3='3.Grand mal/oth epilep' 4='4.Convulsions age 0-5 ' 5='5.Convulsions age >5 ' 6='6.Severe ENT infection' 7='7.Pulmonary tuberculos' 8='8.Other tuberculosis ' 9='9.Chron.obs.pulm.dis ' 10='10.Bacterial pneumon ' 11='11.Asthma ' 12='12.Cong.heart failure' 13='13.Hypertension ' 14='14.Angina ' 15='15.Cellulitis ' 17,18,19 ='17-19.Diabetes A,B,C' 20='20.Hypoglycemia ' 21='21.Gastroenteritis ' 22='22.Kidney urinary inf' 23='23.Dehydration ' 24='24.Iron def.anemia ' 25='25.Nutritional def. ' 26='26.Failure to thrive ' 27='27.Pelvic inflam.dis ' 28='28.Dental conditions '; run; * Input dataset is 72000 observations; * (12 conditions x 6 income levels (quintiles and overall) x 1000 replicates); * Analysis variable is direct-adjusted rate of ambulatory visits (D_AMBVI); * or hospitalizations (D_DISCH). Where adjustment is not possible due to small; * age range, crude rates are used (C_AMBVI and C_DISCH); proc sort data=acs.ambvisreps out=sorted; by acscond _rank_; run; * Label each observation with a replicate number; data reps; length rep 3; set sorted; by acscond _rank_; if first._rank_ then rep=0; rep+1; run; proc sort data=reps; by acscond rep _rank_; run; * Create Q1/Q5 ratios. This just divides the Q1 rate for each replicate by the Q5 rate; data q1q5; set reps; retain q1rate q5rate; by acscond rep _rank_; if first.rep then q1rate=.; if _rank_='U1' and d_ambvi>. then q1rate=d_ambvi; else if _rank_='U1' and c_ambvi>. then q1rate=c_ambvi; if _rank_='U5' and d_ambvi>. then q5rate=d_ambvi; else if _rank_='U5' and c_ambvi>. then q5rate=c_ambvi; if last.rep then do; q1q5ratio=q1rate/q5rate; output; end; keep acscond q1rate q5rate q1q5ratio; run; * Confidence intervals are found by taking the 2.5%ile and the 97.5%ile of the; * distribution of ratios; proc univariate data=q1q5 noprint; by acscond; var q1rate q5rate q1q5ratio; output out=outuni mean=q1 q5 rat median=q1med q5med ratmed pctlpts=2.5 97.5 pctlpre=q1_ q5_ rat_; run; proc print data=outuni label noobs; format acscond acsl. q1 q5 rat q1med q5med ratmed q1_2_5 q1_97_5 q5_2_5 q5_97_5 rat_2_5 rat_97_5 6.3; id acscond; title1 'Ambulatory visit rates Q1 and Q5, and Q1/Q5 ratios for ACS conditions 1997-2000'; title2 'Generated from 1000 bootstrap replicates'; run; proc gchart data=q1q5; vbar q1q5ratio; by acscond; format acscond acsl.; run cancel; * Create Q1/Q5 ratios for hospitalizations; proc sort data=acs.hospreps out=sorted; by acscond _rank_; run; data reps; length rep 3; set sorted; by acscond _rank_; if first._rank_ then rep=0; rep+1; run; proc sort data=reps; by acscond rep _rank_; run; data q1q5; set reps; retain q1rate q5rate; by acscond rep _rank_; if first.rep then q1rate=.; if _rank_='U1' and d_disch>. then q1rate=d_disch; else if _rank_='U1' and c_disch>. then q1rate=c_disch; if _rank_='U5' and d_disch>. then q5rate=d_disch; else if _rank_='U5' and c_disch>. then q5rate=c_disch; if last.rep then do; if q5rate>0 then q1q5ratio=q1rate/q5rate; else q1q5ratio=99999; output; end; keep acscond q1rate q5rate q1q5ratio; run; proc univariate data=q1q5 noprint; by acscond; var q1q5ratio q1rate q5rate; output out=outuni mean=rat q1 q5 median=ratmed pctlpts=2.5 97.5 pctlpre=rat_; run; proc print data=outuni label noobs; format acscond acsl. q1 q5 rat ratmed rat_2_5 rat_97_5 6.3; id acscond; title1 'Hospital visit rates Q1 and Q5, and Q1/Q5 ratios for ACS conditions 1997-2000'; title2 'Generated from 1000 bootstrap replicates'; run; proc gchart data=q1q5; vbar q1q5ratio; by acscond; where q1q5ratio<99999; format acscond acsl.; run cancel; * Calculate V/H ratios; proc sort data=acs.ambvisreps out=sortmed; by acscond _rank_; run; proc sort data=acs.hospreps out=sorthosp; by acscond _rank_; run; data hospvis; merge sortmed(in=a) sorthosp(in=b); by acscond _rank_; if a; run; data hospvis; set hospvis; if d_ambvi>. then do; if d_disch>0 then vhratio=d_ambvi/d_disch; else vhratio=99999; end; else if c_ambvi>. then do; if c_disch>0 then vhratio=c_ambvi/c_disch; else vhratio=99999; end; *keep acscond _rank_ vhratio; run; proc univariate data=hospvis noprint; by acscond _rank_; var d_ambvi d_disch vhratio; output out=outuni mean=ambvi disch ratio median=ambvismed dischmed ratmed pctlpts=2.5 97.5 pctlpre=amb_ dic_ rat_; run; proc print data=outuni label noobs; var ambvismed dischmed ratmed rat_2_5 rat_97_5; format acscond acsl. ambvismed dischmed ratmed rat_2_5 rat_97_5 8.3 ; id _rank_; by acscond; where acscond ne 24; title1 'Ambulatory visit to hospital visit ratios by quintile, ACS conditions 1997-2000'; title2 'Generated from 1000 bootstrap replicates'; run; proc univariate data=hospvis noprint; by acscond _rank_; var c_ambvi c_disch vhratio; where acscond=24; output out=outuni mean=ambvi disch ratio median=ambvismed dischmed ratmed pctlpts=2.5 97.5 pctlpre=amb_ dic_ rat_; run; proc print data=outuni label noobs; var ambvismed dischmed ratmed rat_2_5 rat_97_5; format acscond acsl. ambvismed dischmed ratmed rat_2_5 rat_97_5 8.3 ; id _rank_; by acscond; where acscond=24; title1 'Ambulatory visit to hospital visit ratios by quintile, ACS conditions 1997-2000'; title2 'Generated from 1000 bootstrap replicates'; run; * Generate Q1/Q5 ratios for V/H ratios; data reps; length rep 3; set hospvis; by acscond _rank_; if first._rank_ then rep=0; rep+1; run; proc sort data=reps; by acscond rep _rank_; run; data q1q5; set reps; retain q1ratio q5ratio; by acscond rep _rank_; if first.rep then q1ratio=.; if _rank_='U1' and vhratio>. then q1ratio=vhratio; if _rank_='U5' and vhratio>. then q5ratio=vhratio; if last.rep then do; if q5ratio>0 then q1q5ratio=1/(q1ratio/q5ratio); * Note this inverse because we want the likelihood; * of a hospitalization per visit; else q1q5ratio=99999; output; end; keep acscond q1ratio q5ratio q1q5ratio; run; proc univariate data=q1q5 noprint; by acscond; var q1ratio q5ratio q1q5ratio; output out=outuni mean=q1 q5 rat median=q1med q5med ratmed pctlpts=2.5 97.5 pctlpre=q1_ q5_ rat_; run; proc print data=outuni label noobs; format acscond acsl. q1med q5med ratmed rat_2_5 rat_97_5 8.3; id acscond; var q1med q5med ratmed rat_2_5 rat_97_5; title1 'Q1/Q5 ratio for the Amb. visit to hosp. visit ratios, by quintile: ACS conditions 1997-2000'; title2 'Generated from 1000 bootstrap replicates'; run;