Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Eric Booth <ebooth@ppri.tamu.edu> |

To |
"<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: three way tabulation |

Date |
Thu, 8 Jul 2010 04:49:31 +0000 |

<> Hi Jorge: You can build a 3-way table a number of ways, but part of the challenge is understanding how you're getting to the summary numbers in your table (are the cells counts, sums, averages, etc?). Assuming that you are counting the number of positive, negative, and zero values in var2 and var3 within groups marked by var1--here are 2 methods to build your 3-way table using -outsheet- and -tabout- (from SSC): ********************! clear inp var1 var2 var3 1 1 -1 1 -2 2 2 0 3 2 3 3 3 0 4 3 -2 -2 1 -2 0 3 -1 -1 end //this section just creates the counts by var1// forval n = 2/3 { egen pos`n'a = count(var`n') if var`n'>0, by(var1) bys var1: egen pos`n' = max(pos`n'a) egen neg`n'a = count(var`n') if var`n'<0, by(var1) bys var1: egen neg`n' = max(neg`n'a) egen equiv`n'a = count(var`n') if var`n'==0, by(var1) bys var1: egen equiv`n' = max(equiv`n'a) egen total`n' = rowtotal(pos`n' neg`n' equiv`n') recode pos`n' neg`n' equiv`n' total`n' (.=0) local cells`n' count pos`n'a count neg`n'a count equiv`n'a max total`n' } //example1: using outsheet// preserve drop var2 var3 pos?a neg?a equiv?a bys var1: g i=1==_n drop if i!=1 drop i outsheet using table.xls, replace restore //example2: using tabout// which tabout if _rc ssc install tabout tabout var1 using table.xls, append sum /// c(`cells2' `cells3') h2( | var2 | || | var3 | | |) /// ptotal(none) h3(var1 | Pos | Neg | Equiv | Total | Pos | Neg | Equiv | Total| ) **tabout is more flexible for building/labeling these kinds of tables** ********************! ~ Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu Office: +979.845.6754 On Jul 7, 2010, at 10:41 PM, Mendoza Aldana, Dr Jorge Antonio (WPRO) wrote: > Dear statalist, > Using version 10.1 > Is there a direct way of generating a table like that below (rowvar colvar colvar)? Tab3way doesn't work in this case. > I would appreciate very much your advice. > Thank you, > Jorge > > > var2 var3 > var1 pos neg equiv Total pos neg equiv Total > 1 287 141 16 444 73 403 9 485 > 2 14 4 0 18 82 207 5 294 > 3 0 102 110 0 212 > > > Jorge > > > > > > ==================================================== > This message was scanned for viruses with Trend Micro ScanMail, GFI MailSecurity and GFI MailEssentials by the World Health Organization Regional Office for the Western Pacific. However, the recipient is advised to scan this e-mail and any attached files for viruses. > > Disclaimer: > > This e-mail, together with any attachments, is intended for the named recipients only and is confidential. It may also be privileged or otherwise protected by law. > > If you have received it in error, please notify the sender immediately by reply e-mail and delete it and any attachments from your system. You may not copy or disclose its contents to anyone. > * * 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/

**References**:**st: three way tabulation***From:*"Mendoza Aldana, Dr Jorge Antonio (WPRO)" <MendozaAldanaj@wpro.who.int>

- Prev by Date:
**Re: st: Re: Extracting the t-statistics from a regression output** - Next by Date:
**st: AW: Extracting the t-statistics from a regression output** - Previous by thread:
**st: three way tabulation** - Next by thread:
**st: Re: Extracting the t-statistics from a regression output** - Index(es):