********************************************** * Código Template para ser organizadinho * Claudio R. Lucinda * FEA-RP/USP ********************************************** cd "C:\" sysuse auto, clear * Tabela de Estatísticas Descritivas por tipo domestic vs foreign matrix table1=J(2, 3, 0) local i 0 levelsof foreign, local(colist) foreach c of local colist{ quietly{ local ++i su price if foreign==`c' matrix table1[`i' , 1] = r(mean) matrix table1[`i' , 2] = r(sd) matrix table1[`i' , 3] = r(N) /* tab modo2 if modo1 == `c' matrix table1[`i' , 2] = r(N) tab modo2 if modo2 == `c' matrix table1[`i' , 3] = r(N) */ } } matrix rownames table1 = `colist' matrix colnames table1 = "Média-Dom" "D.P." matrix list table1, format(%9.3f) ti("Est. Desc. Preço") outtable using "teste", mat(table1) replace format(%9.3f) center nobox caption("Est. Desc. Preço") * Gráfico de barras graph bar (mean) price, over(foreign) graph bar (mean) price, over(foreign) scheme(sj) graph bar (mean) price, over(foreign) scheme(sj) title("Preço Médio") ytitle("USD") graph export ".\Teste\fig01.pdf", replace graph export ".\Teste\fig01.wmf", replace * Regressão - Um monte de modelos foreach var in mpg rep78 headroom trunk weight length turn displacement gear_ratio { reg price `var', robust } * Regressão - Salvando os modelos local i=1 foreach var in mpg rep78 headroom trunk weight length turn displacement gear_ratio { reg price `var', robust est store mod_`i' local ++i } est dir estout mod_*, cells(b(star fmt(%9,3f)) t(par)) stats(r2 chi2 p) estout mod_*, cells(b(star fmt(%9,3f)) t(par)) stats(r2 chi2 p) style(tex) estout mod_* using ".\Teste\Modelo.tex", cells(b(star fmt(%9,3f)) t(par)) stats(r2 chi2 p) style(tex) replace estout mod_* using ".\Teste\Modelo_bonitinho.tex", cells(b(star fmt(%9,3f)) t(par)) stats(r2 chi2 p) style(tex) /// prehead("\begin{tabular}{l*{@M}{rr}}" "\hline \hline") posthead("\hline") /// prefoot("\hline") postfoot("\hline \hline" "@starlegend" "\end{tabular}") replace