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

RE: st: Generating comparison tables

From   Roy Wada <>
To   <>
Subject   RE: st: Generating comparison tables
Date   Wed, 22 Apr 2009 10:09:19 -0700

> E.g compare the population in a treatment and placebo group (Columns)
> across multiple different categorical variables (Rows) and have each
> cell contain the frequency and percentage. Finally there should be a
> column including the p value for the difference between the groups
> (test specified by user). I'm sure there is an easy way to do this,
> but sofar I've been spending a lot of time copying and pasting into
> excel....

This is very vague. But you can do something like this. It will give you freq, 
percentage, and p-value, just as you asked.
sysuse auto, clear
ren foreign treatment
egen outcome=cut(mpg), group(3)
qui levelsof outcome

mat pval=.051, .733, .825         /* insert local macro here */
mat colname pval=`r(levels)'
cap erase myfile.txt
bys treatment: outreg2 outcome using myfile, tab
outreg2 using myfile, matrix(pval)
Incidently, the -matrix( )- option was added about a year ago. I don't exactly
remember how it works, but looks like it still going through the e(b) matrix.
Windows Live™ Hotmail®:…more than just e-mail.
*   For searches and help try:

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