Stata
*Memorizing today's date
local date = "`c(current_date)'"
local date = subinstr("`date'"," ","",.)
local results t`date'
capture log close
log using `results'.log
*estout example:
estout gc`i'USnondur gc`i'USdur gc`i'UKnondur gc`i'UKdur ///
using `results'`uncert_basis'`i'durnondurRP.tex, cells(b(star fmt(%10.3f)) se(par)) delim("&") ///
drop(_cons _I* o.* X*) style(tex) collabels(, none) stats(N upval linkpval, fmt(%9.0fc %5.3fc %5.3fc ) ///
labels("Firm-years" "Firm deviations p-value" "Link test p-value" )) eqlabels(none) replace ///
mlabels("US Nondurable" "US Durable" "UK Nondurable" "UK Durable") ///
prehead("\begin{table}[tbhp] \caption{`want`i'' based on `uncert_basis': GLM estimates} \centering \begin{tabular}{lrrrrrrrr}" \hline \hline) ///
posthead(\hline) prefoot(\hline) postfoot(\hline \hline "\end{tabular} \\ {\footnotesize Notes: Cluster-robust standard errors (by firm) in parentheses. * p$\le 0.10$, ** p$\le 0.05$, *** p$\le 0.01$. } \end{table} \pagebreak") ///
varwidth(30) starlevels(* 0.1 ** 0.05 *** 0.01) ///
varlabel(L.HHI "Sales Concentration" L.divers "Global Sales Diversification\$_{t-1}\$" L.HHI1 "Domestic Sales Only" L.multi "Foreign Productive Assets\$_{t-1}\$" ///
L.uncert "Panel Data Shocks\$_{t-1}\$" L.firmAR "Firm AR Shocks\$_{t-1}\$" L.NE2TA "(Net Eqty Sales/Total Assets)\$_{t-1}\$" ///
L.uncert2 "Panel Data Volatility" L.firmAR2 "FirmAR Volatility" L.logLabour "Log(Employment)\$_{t-1}\$" ///
L.Cash2TA "(Cash/Total Assets)\$_{t-1}\$" L.D2TA "(Total Debt/Total Assets)\$_{t-1}\$" L.diversEU "European Sales Diversification\$_{t-1}\$")
*estout example
estout SQ FE RE AREG, ///
cells(b(star fmt(%10.3f)) se(par)) delim("&") ///
style(fixed) stats(N r2, fmt(%9.0fc %5.3fc )) starlevels(* 0.1 ** 0.05 *** 0.01)
* dropping extreme values (could be adjusted for winsorizing as well)
* list of variables to winsorize/check for extreme values:
local screen nprice
* lower cut-point
local lcut 1
* higher cut-point
local hcut 99
foreach variab of local screen {
su `variab', d
* it is done by type_id US, could be by firm_id year.. etc.
egen `variab'`lcut'=pctile(`variab'), p(`lcut') by(type_id US)
egen `variab'`hcut'=pctile(`variab'), p(`hcut') by(type_id US)
replace `variab'=. if `variab'<`variab'`lcut'
replace `variab'=. if `variab'>`variab'`hcut' & `variab'~=.
drop `variab'`lcut' `variab'`hcut'
}
* reporting descriptive statistics
local vars price_hour time_spent
foreach var of local vars {
qui su `var' if xxx==1 , d
di " `var' & " %7.2f r(mean) " & " %7.2f r(sd) " & " %7.2f r(p25) " & " %7.2f r(p50) " &" %7.2f r(p75) " & " %7.0fc r(N) "
}
local vars price_hour time_spent
foreach var of local vars {
qui ttest `var' if xxx==1 , by(OWO)
di " `var' & " %7.2f r(mu_1) " & " %7.2f r(sd_1) " & " %7.0fc r(N_1) " & " ///
%7.2f r(mu_2) " & " %7.2f r(sd_2) " & " %7.0fc r(N_2) " & " %7.2f r(mu_1)-r(mu_2) " & " ///
%7.2f r(p)
}