-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathesttab_Latex_Sample.do
112 lines (88 loc) · 3.96 KB
/
esttab_Latex_Sample.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
Author: Anthony D'Agostino (ald2187 [at] columbia.edu)
Filename: esttab_Latex_Sample.do
Date Created: 05/27/2016
Dataset:
Purpose:
*/
cap program drop sampleRun
program define sampleRun
syntax, dv(string) [subsetDescription(string)]
/*
dv: dependent variable.
subsetDescription: enters into header.
*/
eststo clear
set more off
loc full_controls "marital i.act_status hhsize edu c.age##c.age i.caste i.hh_rating"
loc notes "Controls include control1 control2 control3 control4 control5$^2$. Add more description here. Further description. Much more description. No problems with column width here. Can also do math, $\frac{3}{4} \leq \frac{4}{3}$, and more description here."
loc lbl: variable label `dv'
qui eststo: reg `dv' ib0.sex##c.Class1_pct_1km [pweight = weight], vce(cluster vill_state_98)
su `dv' if e(sample), mean
loc mymean: di %8.2f r(mean)
estadd loc mD `mymean', replace
estadd loc statefe "", replace
qui eststo: reg `dv' `full_controls' ib0.sex##c.Class1_pct_1km [pweight = weight], vce(cluster vill_state_98)
su `dv' if e(sample), mean
loc mymean: di %8.2f r(mean)
estadd loc mD `mymean', replace
estadd loc statefe "", replace
estadd loc controls "$\checkmark$", replace
qui eststo: reg `dv' `full_controls' i.state_code ib0.sex##c.Class1_pct_1km [pweight = weight], vce(cluster vill_state_98)
su `dv' if e(sample), mean
loc mymean: di %8.2f r(mean)
estadd loc mD `mymean', replace
estadd loc statefe "$\checkmark$", replace
estadd loc controls "$\checkmark$", replace
qui eststo: reg `dv' ib0.sex##c.Class1_pct_1km if `dv' > 0 [pweight = weight], vce(cluster vill_state_98)
su `dv' if e(sample), mean
loc mymean: di %8.2f r(mean)
estadd loc mD `mymean', replace
estadd loc statefe "", replace
qui eststo: reg `dv' `full_controls' ib0.sex##c.Class1_pct_1km if `dv' > 0 [pweight = weight], vce(cluster vill_state_98)
su `dv' if e(sample), mean
loc mymean: di %8.2f r(mean)
estadd loc mD `mymean', replace
estadd loc statefe "", replace
estadd loc controls "$\checkmark$", replace
qui eststo: reg `dv' `full_controls' i.state_code ib0.sex##c.Class1_pct_1km if `dv' > 0 [pweight = weight], vce(cluster vill_state_98)
su `dv' if e(sample), mean
loc mymean: di %8.2f r(mean)
estadd loc mD `mymean', replace
estadd loc statefe "$\checkmark$", replace
estadd loc controls "$\checkmark$", replace
loc dv_no_us = subinstr("`dv'", "_", "", . )
#delimit ;
loc heading "Insert Table Header Here";
loc odir "$tabBase/1982/timeModels";
cap mkdir "`odir'";
loc ofile "`odir'/timeModels_FAKE.tex";
loc resize 1.0;
esttab using "`ofile'", se r2 label compress replace obslast depvars nocons nomtitles nonum
keep(1.sex Class1_pct_1km 1.sex#c.Class1_pct_1km) legend star(* 0.10 ** 0.05 *** 0.01) title("`heading'") varlabels(1.sex "Variable 1" Class1_pct_1km "Variable 2" 1.sex#c.Class1_pct_1km "Variable 1 $\times\$ Variable 2")
s(N mD controls statefe r2_a, labels("N" "DV Mean" "Controls" "State FE" "Adj. R$^2$"))
prehead(
\begin{table}[!htbp]
\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\label{tab:LFPR`dv_no_us'}
\caption{`heading'}
\resizebox{`resize'\textwidth}{!}{
\begin{tabular}{l*{@M}{c}}\tabularnewline \hline
&\multicolumn{3}{c}{Days}&\multicolumn{3}{c}{Days $\times\$ 1(Days$>$0)}\\\cmidrule(l){2-4}\cmidrule(l){5-7}
)
posthead(\hline \hline \)
prefoot(\hline \noalign{\smallskip})
postfoot(
\hline\hline \noalign{\smallskip}
\end{tabular}
}
\medskip
\begin{minipage}{`resize'\textwidth}
\footnotesize Notes: "`notes'" \\
@starlegend
\end{minipage}
\end{table}
);
#delimit cr
end