Hi all,
This post concerns estout (SSC, by Ben Jann) in Stata 16. I wonder how one can add series of scalars as columns to a wide table. Multiple posts have shown 1) how to estadd scalars (e.g. here); and 2) how to display these scalars to the bottom of a long table (e.g. here). I am struggling to synthesize the methods to make wide tables.
Example (with sysuse auto). The ideal output looks like this, from which I have difficulty adding the rightmost column of p valus from chi2 independent test (stored as scalars from tab x y, chi2) in red.

The difficulties are combining these aspects:
1) properly store the chi2 p results as there are P values from both the ttest and the chi2 test
2) retain the stars for these scalars (Andrew did show a "manual" way here, would this be the way?)
3) printing them as columns
I was able to use the following script to produce the first six columns (i.e. excl. the rightmost):
Output:
Appreciate any pointers or advice!
This post concerns estout (SSC, by Ben Jann) in Stata 16. I wonder how one can add series of scalars as columns to a wide table. Multiple posts have shown 1) how to estadd scalars (e.g. here); and 2) how to display these scalars to the bottom of a long table (e.g. here). I am struggling to synthesize the methods to make wide tables.
Example (with sysuse auto). The ideal output looks like this, from which I have difficulty adding the rightmost column of p valus from chi2 independent test (stored as scalars from tab x y, chi2) in red.
The difficulties are combining these aspects:
1) properly store the chi2 p results as there are P values from both the ttest and the chi2 test
2) retain the stars for these scalars (Andrew did show a "manual" way here, would this be the way?)
3) printing them as columns
I was able to use the following script to produce the first six columns (i.e. excl. the rightmost):
Code:
version 16 clear all set linesize 120 set more off * Input data set sysuse auto eststo clear eststo dom: qui estpost sum price mpg if foreign == 0 eststo for: qui estpost sum price mpg if foreign == 1 eststo dom_for: qui estpost ttest price mpg, by(foreign) unequal eststo price_c2: qui estpost tab price foreign, chi2 eststo mpg_c2: qui estpost tab mpg foreign, chi2 esttab dom for dom_for, replace star(* 0.10 ** 0.05 *** 0.01) nonumber noobs label /// alignment(rrrr) /// cells("count(pattern(1 1 0 0) fmt(0)) mean(pattern(1 1 0 0) fmt(2)) b(star pattern(0 0 1 0) fmt(2))") /// mtitle("Domestic" "Foreign" "ttest") /// collabels("N" "Mean" "Mean Diff.") eststo clear
Code:
---------------------------------------------------------------------------------------- Domestic Foreign ttest N Mean N Mean Mean Diff. ---------------------------------------------------------------------------------------- Price 52 6072.42 22 6384.68 -312.26 Mileage (mpg) 52 19.83 22 24.77 -4.95*** ----------------------------------------------------------------------------------------
Appreciate any pointers or advice!
Comment