Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: st: AW: Formatting tables with estpost & esttab


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: AW: Formatting tables with estpost & esttab
Date   Mon, 5 Oct 2009 09:31:41 +0200

<> 

Not sure how you would get the upper panel into esttab, but you can sure get
it into a Stata file which you could export in any way you see fit...


*************
sysuse auto, clear

tempname hdle

capt erase info.dta

postfile `hdle' str10 var dommean domsd /* 
*/ formean forsd pval overallmean overallsd /* 
*/ using info


foreach var of varlist price mpg{
	sum `var' if !for
	loc dommean=r(mean)
	loc domsd=r(sd)
	sum `var' if for
	loc formean=r(mean)
	loc forsd=r(sd)
	ttest `var', by(foreign)	
	local pval=r(p)
	sum `var'
	post `hdle' ("`var'") (`dommean') (`domsd') /* 
	*/ (`formean') (`forsd') (`pval') /* 
	*/ (r(mean)) (r(sd))
}

postclose `hdle'

use info, clear
l, abbrev(12) noobs sep(0)
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Eduardo Nunez
Gesendet: Montag, 5. Oktober 2009 01:18
An: [email protected]
Betreff: Re: st: AW: Formatting tables with estpost & esttab

Hi Martin,

It did work pretty good for discrete variables. For continuous
variables, I would like a code that provide me side by side the
meanpuls-minusSD for the two categories of Foreign and a third column
with the p-value from ttest.

Thank you so much in advance,

Eduardo



On Sun, Oct 4, 2009 at 5:36 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
>
>
> You can -estpost- all these results in a quite straightforward manner, and
> then -esttab- them with the matrix function of this command.  For
instance,
> the lower panel of your table would be
>
> ***
> sysuse auto, clear
>
> estpost tab rep for, chi2
> esttab ., main(b) aux(colpct)  /*
> */ nostar unstack noobs nonum nonote  /*
> */ sca("chi2 Chi2 Value" "p corr. p-value")  /*
> */ sfmt(%4.3fc) wide compress
>
> ***
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Eduardo Nunez
> Gesendet: Sonntag, 4. Oktober 2009 22:33
> An: [email protected]
> Betreff: st: Formatting tables with estpost & esttab
>
> Dear statalister,
>
> I have been trying to get the right code in estpost and esttab
> (without success) to format tables as the example below (using auto
> dataset):
>
>                         Domestic (N=52)                Foreign (N=22)
> P-value         Total (N=74)
>
> Price                       6179.3ą3189.0               6070.1ą2221.0
> 0.015           6146.0ą2912.4
>
> Mileage (mpg)                  19.54ą4.753              25.29ą6.310
> 0.006           21.29ą5.866
>
> Repair Record 1978, n(%)
> *0.000
> 1                                2 (4.17)
> 0 (0)
>        2 (2.9)
> 2                               8 (16.67)
> 0 (0)
>        8 (11.59)
> 3                               27 (56.25)
> 3 (14.29)                               30 (43.48)
> 4                               9 (18.75)
> 9 (42.86)                               18 (26.09)
> 5                               2 (4.17)
> 9 (42.86)                               11 (15.94)
>
> *Omnibus P-value
>
>
>
>
> The meanąSD  [or median (IQR) when appropriate] for each variable and
> for the total population with the p-value corresponding (either a
> t-test or ranksum test);
> For discrete variables, the n (%)...count(col percentage) and the
> p-value corresponding to chi2.
>
> I would really appreciate any help on this issue.
>
> Best wishes,
>
> Eduardo
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index