* Automation for b * return list r() * ereturn list e() * c(), s(), n() * Output file payout 2007+2008+2009+2010: * file.matrix: all baby kid adult midage elder veld * row names: cost los death icu ae * col names: _b(como1) _se(como1) _b(como2) _se(como2)... _b(como32) _se(como32) * each matrix(r*c)=(5*96) * y= 2007, 2008, 2009, 2010, all { * ili_inoutpt_a 0 999 all `z' * ili_inoutpt 0 15 a0_15 `z' * ili_inoutpt 15 65 a15_65 `z' * ili_inoutpt 65 999 a65up `z' * } * args minage maxage agegrp * keep if age >= `minage' & age<`maxage' cd "/Users/RJCC/Documents/rjcc3/ili" include _init include _indata import excel "/Users/RJCC/Documents/rjcc3/ili/como_list.xls", sheet("como") /// firstrow case(lower) clear forvalues i=1(1)47 { scalar c`i'=como[`i'] } program rn rename (asth2 allrh2 atopd2 cong2 tb2 cancer2 dm2 hlipid2 thyr2 /// chf2 vhd2 cad2 heart2 rhy2 htn2 /// cva2 demen2 epil2 paod2 copd2 pulcer2 vhepa2 cirr2 hcc2 /// renal2 esrd2 preg2 gout2 flu2 transplant2 hiv2 sle2 rha2 aks2 /// alle2 cv2 cvc2 card2 neuro2 vas2 lung2 gi2 /// kidney2 meta2 endoc2 autoim2 imdef2) /// (c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 /// c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 /// c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 /// c45 c46 c47) end program rn2 rename (c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 /// c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 /// c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 /// c45 c46 c47) /// (asth allrh atopd cong tb cancer dm hlipid thyr /// chf vhd cad heart rhy htn /// cva demen epil paod copd pulcer vhepa cirr hcc /// renal esrd preg gout flu transplant hiv sle rha aks /// alle cv cvc card neuro vas lung gi /// kidney meta endoc autoim imdef) end program ilc args minage maxage agegrp z indata `z' rn keep if age >= `minage' & age<`maxage' * cost, los => ln(cost), ln(los) in _indata.do tab c1, matcell(C1) matrix P_`agegrp' = (`minage', `maxage', 100*C1[2,1]/(C1[1,1]+C1[2,1])) matrix coln P_`agegrp'= minage maxage c1 reg bcost sex2 c1 matrix COST = (`minage', `maxage', exp(_b[c1]), exp(_b[c1]-1.96*_se[c1]), exp(_b[c1]+1.96*_se[c1])) matrix coln COST= minage maxage c1 c1_L c1_H reg blos sex2 c1 matrix LOS = (`minage', `maxage', exp(_b[c1]), exp(_b[c1]-1.96*_se[c1]), exp(_b[c1]+1.96*_se[c1])) reg bdaycost sex2 c1 matrix DAYCOST = (`minage', `maxage', exp(_b[c1]), exp(_b[c1]-1.96*_se[c1]), exp(_b[c1]+1.96*_se[c1])) distinct die2 if r(ndistinct)>1 { logit die2 sex2 c1, or matrix DIE = (`minage', `maxage', exp(_b[c1]), exp(_b[c1]-1.96*_se[c1]), exp(_b[c1]+1.96*_se[c1])) } else matrix DIE = (`minage', `maxage', 0,0,0) distinct icu if r(ndistinct)>1 { logit icu sex2 c1, or matrix ICU = (`minage', `maxage', exp(_b[c1]), exp(_b[c1]-1.96*_se[c1]), exp(_b[c1]+1.96*_se[c1])) } else matrix ICU = (`minage', `maxage', 0,0,0) distinct ae if r(ndistinct)>1 { logit ae sex2 c1, or matrix AE = (`minage', `maxage', exp(_b[c1]), exp(_b[c1]-1.96*_se[c1]), exp(_b[c1]+1.96*_se[c1])) } else matrix AE = (`minage', `maxage',0,0,0) forvalues i= 2(1) 47 { tab c`i', matcell(C`i') matrix Pa_`agegrp' = (100*C`i'[2,1]/(C`i'[1,1]+C`i'[2,1])) matrix coln Pa_`agegrp'= c`i' matrix P_`agegrp' = P_`agegrp', Pa_`agegrp' reg bcost sex2 c`i' matrix COSTa = (exp(_b[c`i']), exp(_b[c`i']-1.96*_se[c`i']), exp(_b[c`i']+1.96*_se[c`i'])) matrix coln COSTa= c`i' c`i'_L c`i'_H matrix COST = COST, COSTa reg blos sex2 c`i' matrix LOS = LOS, (exp(_b[c`i']), exp(_b[c`i']-1.96*_se[c`i']), exp(_b[c`i']+1.96*_se[c`i'])) reg bdaycost sex2 c`i' matrix DAYCOST = DAYCOST, (exp(_b[c`i']), exp(_b[c`i']-1.96*_se[c`i']), exp(_b[c`i']+1.96*_se[c`i'])) distinct die2 if r(ndistinct)>1 { logit die2 sex2 c`i', or matrix DIE = DIE, (exp(_b[c`i']), exp(_b[c`i']-1.96*_se[c`i']), exp(_b[c`i']+1.96*_se[c`i'])) } else matrix DIE = DIE, (0,0,0) distinct icu if r(ndistinct)>1 { logit icu sex2 c`i', or matrix ICU = ICU, (exp(_b[c`i']), exp(_b[c`i']-1.96*_se[c`i']), exp(_b[c`i']+1.96*_se[c`i'])) } else matrix ICU = ICU, (0,0,0) distinct ae if r(ndistinct)>1 { logit ae sex2 c`i', or matrix AE = AE, (exp(_b[c`i']), exp(_b[c`i']-1.96*_se[c`i']), exp(_b[c`i']+1.96*_se[c`i'])) } else matrix AE = AE, (0,0,0) } matrix `agegrp'=COST\LOS\DAYCOST\DIE\ICU\AE end local year "2007 2008 2009 2010 all" matrix drop _all foreach z of local year { ilc 0 999 all `z' ilc 0 15 a0_15 `z' ilc 15 65 a15_65 `z' ilc 65 999 a65up `z' clear matrix PREV_`z'=P_all\P_a0_15\P_a15_65\P_a65up svmat PREV_`z', names(col) rn2 export excel using "ilc_crude", sheet("PREV_`z'") firstrow(variables) sheetmodify matrix ili_como_`z'=all\a0_15\a15_65\a65up clear svmat ili_como_`z', names(col) rn2 export excel using "ilc_crude", sheet("ili_como_`z'") firstrow(variables) sheetmodify } * exit, clear STATA