Esttab Easily Change Number of Scalar Decimals | Exporting Results Struggle
Вставка
- Опубліковано 18 вер 2024
- Change Number of Scalar Decimals | Esttab:
In this video I show you how to easily set the number of decimals for each scalar in Stata Esttab for output to Overleaf.
Code:
global path "[YOUR PATH HERE]"
sysuse auto, clear
global note1="Note: Robust Standard Errors in Parenthesis. Controls include Foreign, Headroom, Repair Record."
global sources="Source: Stata System Auto Data."
est clear
eststo: reg price mpg weight length, robust
estadd local controls "No"
qui sum `e(depvar)' if e(sample)
estadd scalar mean=`r(mean)'
estadd scalar sd=`r(sd)'
eststo: reg price mpg weight length foreign headroom rep78, robust
estadd local controls "Yes"
qui sum `e(depvar)' if e(sample)
estadd scalar mean=r(mean)
estadd scalar sd=r(sd)
#delimit ;
esttab * using "${path}\Reg Format Scalars.tex",
se(3) /// SE with 3 Decimal Places
b(2) /// Coefficients with 2 Decimal Places
label
replace /// Replace File
title(Regression with Mean \label{tab1}) /// Title of Tabel
mtitles("No Controls" "With Controls") /// Column Titles
keep(mpg weight length) /// Don't want all Control Coefficients
coeflabels(mpg "Miles Per Gallon"
weight "Weight of Car" length "Length of Car") /// Label Variables
scalars(
"mean Mean Price"
"sd Std. Dev Price"
"r2 R^{2}"
"N N. Obs"
"controls Controls"
) ///Which Extra Stuff You Want In
sfmt(
%9.2f
%9.2f
%9.4f
%9.0f
)
nonotes /// Suppress Automatically Generated Notes
addnote("$note1" ///Add your Own Note
"$sources" ///Space/New Line Puts Next Note on New Line
)
;
#delimit cr;