Statalist


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

Re: st: dumb cross-tab question


From   "E. Paul Wileyto" <epw@mail.med.upenn.edu>
To   statalist@hsphsun2.harvard.edu
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.

P

Maarten buis wrote:

--- "E. Paul Wileyto" <epw@mail.med.upenn.edu> 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
preserve
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)
restore
*------------------- end example -----------------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

-- 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

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ *
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/

--
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

215-746-7147
Fax: 215-746-7140
epw@mail.med.upenn.edu
http://mail.med.upenn.edu/~epw/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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