-
Notifications
You must be signed in to change notification settings - Fork 0
/
esttab - latex.do
76 lines (51 loc) · 2.23 KB
/
esttab - latex.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
sysuse census.dta, clear
//change this file path to your own file path
global output "/Users/linglingpeng/Downloads/FreshEBT/Lingling/blog - output"
//run a list of regressions
eststo reg1: qui reg death marriage pop
eststo reg2: qui reg death popurban
eststo reg3: qui reg divorce marriage pop
local regressions reg1 reg2 reg3
//a basic version of Latex table:
esttab `regress' using "$output/reg_1.tex", replace
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
*** Latex table
//table with three panels
//NE region only
qui reg death marriage if region == 1
est store ne1
qui reg divorce marriage pop if region == 1
est store ne2
//South region only
qui reg death marriage if region == 3
est store s1
qui reg divorce marriage pop if region ==3
est store s2
//West region only
qui reg death marriage if region == 4
est store w1
qui reg divorce marriage pop if region ==4
est store w2
//top panel
esttab ne1 ne2 using "$output/panel.tex", ///
prehead("\begin{table}[htbp]\centering \\ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \\ \caption{Title of your table} \\ \begin{tabular}{l*{2}{c}} \hline\hline") ///
posthead("\hline \\ \multicolumn{2}{c}{\textbf{Panel A: NE Region}} \\\\[-1ex]") ///
fragment ///
mtitles("Num of Death" "Num of Divorces") stats(r2 N, labels(R-squared "N. of cases")) b(%8.3f) se(%8.3f) replace
eststo clear
//middle panel
esttab s1 s2 using "$output/panel.tex", ///
posthead("\hline \\ \multicolumn{2}{c}{\textbf{Panel B: South Region}} \\\\[-1ex]") ///
fragment ///
append ///
r2 b(%8.3f) se(%8.3f) stats(r2 N, labels(R-squared "N. of cases")) nomtitles nonumbers
eststo clear
//bottom panel
esttab w1 w2 using "$output/panel.tex", ///
posthead("\hline \\ \multicolumn{2}{c}{\textbf{Panel C: West Region}} \\\\[-1ex]") ///
fragment ///
append ///
r2 b(%8.3f) se(%8.3f) stats(r2 N, labels(R-squared "N. of cases")) nomtitles nonumbers ///
prefoot("\hline") ///
postfoot("\hline\hline \multicolumn{5}{l}{\footnotesize Standard errors in parentheses}\\\multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\ \end{tabular} \\ \end{table}")