[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: dumb cross-tab question

From   Maarten buis <>
Subject   Re: st: dumb cross-tab question
Date   Thu, 29 Nov 2007 12:40:47 +0000 (GMT)

--- "E. Paul Wileyto" <> wrote:
> Is there a quick way to get Stata to format a two-way table showing 
> means, SEs, and CIs for a third variable?
> tabulate summarize doesn't seem to do SEs and CIs
> tabstat gets angry if I try to give it two by variables.

Nick gave some code, and I too was busy along his line, with a slightly
different twist: 

*---------------- begin example -------------------------
sysuse auto, clear
collapse (mean) mean=mpg (sd) sd=mpg (count) N=mpg ///
         if !missing(rep78,foreign), by(foreign rep78) 
gen se = sd/sqrt(N)
gen df = N-1
gen lb = mean - invttail(df,0.025)*se
gen ub = mean + invttail(df,0.025)*se
drop sd N df
reshape wide mean se lb ub, i(rep78) j(foreign)
mkmat mean0-ub1, matrix(table) rownames(rep78)
matrix colnames table = domestic:mean domestic:se domestic:lb  ///
                        domestic:ub foreign:mean foreign:se    ///
                        foreign:lb foreign:ub
matlist table, format(%9.2f) rowtitle("repair record") tw(13)
*------------------- end example -----------------------------
(For more on how to use examples I sent to the Statalist, see )

-- Maarten

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
*   For searches and help try:

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