Hi, I'm having a hard time trying to export three different tabstats to three different excel sheets using a loop so at the end I get sheet (indicador s_i) with the matrix results from local s_i... and finally the one with local w. The code actually estimates the tables correctly, however, the sheets get overwritten and in the end I only get the last tabstat on the three sheets. What should I do?
*Tablas de media y desviacion estandar de los indicadores 1996 y 2010
use indices_1996-2010
foreach a in s_i i w {
putexcel set indicadores_practica.xls, sheet(indicador `a') modify
local s_i "ind1_96_3 ind2_96_2 ind3_96_8 ind4_96_7 ind4_96_17 ind5_96_4"
local i "ind1_96_3_i ind2_96_2_i ind3_96_8_i ind4_96_7_i ind4_96_17_i ind5_96_4_i"
local w "ind1_96_3_w ind2_96_2_w ind3_96_8_w ind4_96_13_w ind4_96_17_w ind5_96_4_w"
foreach n in "`s_i'" "`i'" "`w'" {
tabstat `n', stat(mean sd) save
matlist r(StatTotal)
matrix results = r(StatTotal)'
matlist results
putexcel A1=matrix(results), names nformat(number_d2)
}
}
*Tablas de media y desviacion estandar de los indicadores 1996 y 2010
use indices_1996-2010
foreach a in s_i i w {
putexcel set indicadores_practica.xls, sheet(indicador `a') modify
local s_i "ind1_96_3 ind2_96_2 ind3_96_8 ind4_96_7 ind4_96_17 ind5_96_4"
local i "ind1_96_3_i ind2_96_2_i ind3_96_8_i ind4_96_7_i ind4_96_17_i ind5_96_4_i"
local w "ind1_96_3_w ind2_96_2_w ind3_96_8_w ind4_96_13_w ind4_96_17_w ind5_96_4_w"
foreach n in "`s_i'" "`i'" "`w'" {
tabstat `n', stat(mean sd) save
matlist r(StatTotal)
matrix results = r(StatTotal)'
matlist results
putexcel A1=matrix(results), names nformat(number_d2)
}
}
Comment