> Dear Statalisters,
> I am wondering if there is a smart way to prepare a table in the
> following format:
Note that outreg2 is -byable- as well. ctitle( ) locaitons are
controlled by comma. You can insert whatever totoal you want wherever
you want.
sysuse auto, clear
gen white=cond(uniform()>.5,1,0)
gen black=cond(white==1,0,1)
gen male=cond(uniform()>.5,1,0)
gen female=cond(male==1,0,1)
outreg2 using myfile if white==1 & male==1, sum(log) eqkeep(mean N)
cttop(white, male) drop(white male female) excel replace
outreg2 using myfile if white==1 & female==1, sum(log) eqkeep(mean N)
cttop( , female) drop(white male female) excel
outreg2 using myfile if white==1, sum(log) eqkeep(mean N) cttop( ,
total) drop(white male female) excel
outreg2 using myfile if black==1 & male==1, sum(log) eqkeep(mean N)
cttop(black, male) drop(white male female) excel
outreg2 using myfile if black==1 & female==1, sum(log) eqkeep(mean N)
cttop( , female) drop(white male female) excel
outreg2 using myfile if black==1, sum(log) eqkeep(mean N) cttop( ,
total) drop(white male female) excel
YOU SHOULD CONFIRM THAT YOU ARE GETTING THE NUMBERS YOU THINK YOU
SHOULD BE GETTING.
Roy
P.S. Come to think of it, there was some guy who wanted a 2x2
cross-tabulation. You should be able to build one from scratch like
this by using -cross- with one variable at time combined with -if- and
control the output using -stats( )- and ctitle( ).
*
* 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/