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

Re: st: dumb cross-tab question

From   "E. Paul Wileyto" <>
Subject   Re: st: dumb cross-tab question
Date   Thu, 29 Nov 2007 08:05:56 -0500

Thanks. Your example is the sort of solution that I came up with.
It's a script I'll be needing in a general way, so I'll probably turn it into an ado file.


Maarten buis wrote:

--- "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
now. *
* For searches and help try:

E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA 19104-3309

Fax: 215-746-7140
* For searches and help try:

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