Alexandra de Montrichard <[email protected]> wrote a day or so ago:
I need to produce a cross tab table that includes several different
variables in the rows. Var1 is a catergorical variable with three values
and var2, var3, var4, and var5 are yes/no variables with values of 0
or 1. I would like the table to give me row percentages and look more or
less like this:
var1=A var1=B var1=C
var2 .05 .10 .85
var3 .20 .20 .60
var4 .30 .40 .30
var5 .40 .50 .10
and David Harrison <[email protected]> offered the suggestion:
You can get the transpose of this using -table-
table var1, c(mean var2 mean var3 mean var4 mean var5)
An ado command for producing publication quality tables from Stata
called -tabout- will also solve this for you, using the same logic as
the table command suggested by David. In addition, -tabout- will
provide you will tab delimited output (or TeX) to make it easier to
export your tables into a spreadsheet or word processor.
The table produced by -tabout- will be transposed to the one you've
shown (the same as for the -table- command). But you can use the tab
delimited option in -tabout- to export the file into a spreadsheet and
then use the transpose command in the spreadsheet to flip it around.
The syntax for the above table (not yet transposed) would be very
similar to the -table- syntax:
tabout var1 using myfile.txt, c(mean var2 mean var3 mean var4 mean
var5) f(%9.2f)
In addition, there are options for determining column headers and row
labels and so forth, and the ability to have multiple rows of
different variables.
If you do want to use the -tabout- approach, see the tutorial
http://www.acirrt.com/watson/tabout/
Finally, -tabout- can be found on the ssc archives:
ssc install tabout
--
Kind regards,
Ian
-------------------------------
Ian Watson
Senior Researcher
acirrt, University of Sydney
NSW, 2006, Australia
phone: 02 9351 5622
email:[email protected]
www.acirrt.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/