Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Three way table with tabout


From   Ángel Rodríguez Laso <angelrlaso@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Three way table with tabout
Date   Wed, 21 Apr 2010 12:43:09 +0200

Sorry if this message has appeared in the list already: I cannot see
it in the archive.


Here is Ian's answer which sorts out the problem:


It's hard knowing what you want without seeing a final table.

But, have you tried playing around with the h1 h2 or h3 settings? For example:

sysuse nlsw88
tabout race married if south==0 using ian.txt, c(row) replace
h1("Married by race (row %)") ///
h2( | Single | Married | Total) h3("Doesn't live in south") lines(none)
tabout race married if south==1 using ian.txt, c(row) append h1("Lives
in south") h2(nil) h3(nil)


gives you:

Married by race (row %)
Single Married Total
Doesn't live in south

white 31.9 68.1 100.0
black 55.2 44.8 100.0
other 26.1 73.9 100.0
Total 35.6 64.4 100.0
Lives in south

white 25.6 74.4 100.0
black 51.7 48.3 100.0
other 66.7 33.3 100.0
Total 36.1 63.9 100.0

which is tab delimited and will line up properly when you get it into Excel.

Cheers
Ian


El día 14 de abril de 2010 19:29, Ángel Rodríguez Laso
<angelrlaso@gmail.com> escribió:
> Dear Statalisters,
>
> Using Stata 9.2.
>
> Is it possible to get a three way table from tabout?
>
> I would like to have a table of health status by age groups for men
> and bellow another one for women that I can easily export to Excel,
> but I'd rather have in the first row the health status variable label,
> in the second the first value label for sex (men), in the subsequent
> rows the percentages of different health status by age groups in men,
> then the second value label for sex (women) and finally the
> percentages of health status by age groups in women.
>
> I've tried with topf:
>
> tabout agegroups healthstatus using luisa.xls if sex==1, replace svy
> c(row ci) per f(1 1) layout(cb) h3(nil) cisep(-) ///
>
> npos(col)style(tab)stats(chi2) topf(top.txt) topstr(MEN)
>
> tabout agegroups healthstatus using luisa.xls if sex==2, append svy
> c(row ci) per f(1 1) layout(cb) h3(nil) cisep(-) ///
>
> npos(col)style(tab)stats(chi2)topf(top.txt) topstr(WOMEN)
>
>
>
> but then I get the sex value labels before the health status variable
> label, which is not the natural way to show the results.
>
> Tabout does not support -bysort sex-
>
> Many thanks,
>
> Angel Rodriguez-Laso
> *
> *   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/
>

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


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