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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
RE: st: RE: Summary statistics table problem |

Date |
Wed, 29 Oct 2008 13:15:57 -0000 |

Changing the notation, George seems to be asking this: 1. He has variables x1, x2, up that he wants on the _rows_ of a table. 2. He has a variable y whose categories he wants as the _columns_ of a table. 3. He wants the means of each x given y inside the table. If so, I suspect this would be a lot easier if the x's were -reshape long-ed into one. I wouldn't try to program it as a table problem. It's more a matter of data management upstream of the tabulation. Nick n.j.cox@durham.ac.uk George Hoffman In Martin's solution, the x is just a dummy. The rows are the contents - means of the var1 .. Varn - for each value of x, which in this case is just a single dummy entry. The columns are the values of rep78 - which are labels by their values Thanks for your thoughts - I'm thinking there is already a way to do this that I'm somehow overlooking, because it seems like a common function. Matt Spittal > Adding labels to the table is no problem. You just need to define what the > labels are first with the -label define- and -label values- commands. Here is > an illustration: > > // Martin's code > sysuse auto, clear > generate x = 1 > > // add labels > label define rep78 1 "Very good" 2 "Good" 3 "Average" 4 "Poor" 5 "Very poor" > label values rep78 rep78 > table x rep78, contents(mean price mean mpg) George Hoffman > Yes, this works, except for no row labels, but I can live with this. > I might be inspired to write something to 'fix' this problem. Martin Weiss >> Even dirtier: >> >> ********* >> sysuse auto, clear >> g x=1 >> table x rep78, contents(mean price mean mpg ) >> ********* George Hoffman >> thanks, but not quite. >> Tabstat var1 var2 ... Varn, stat(mean) by(byvar) either: >> col(var): yields columns of the var1, var2, with the by(byvar) as rows >> Col(stat): yields sequential single columns of output for each var1..varn >> >> I'm looking for the by(byvar) to appear in columns side by side, with rows >> for var1...varn Martin Weiss >>> -tabstat var1 var2, statistics( mean ) by(Hour6) nototal >> columns(variables)- >>> ? George Hoffman >>> This should be simple, but I can't find a straightforward way to do this. >>> Xt dataset, with hours 1-48 for time, also summarized by hour6 (1-6, >>> 7-12,...) >>> Many row variables. >>> >>> I want a table of means by hour6: >>> >>> Var Hour6 >>> 1 2 3 4 5 6 7 8 >>> var1 50 55 55 57 60 62 61 57 >>> var2 47 34 23 12 6 5 7 6 >>> Etc * * 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**:**RE: st: RE: Summary statistics table problem***From:*"Matt Spittal" <Matt.Spittal@cancervic.org.au>

**Re: st: RE: Summary statistics table problem***From:*George Hoffman <ghoffman@mcw.edu>

- Prev by Date:
**st: RE: graphing a series of vectors (latent growth curve model estimate summaries)** - Next by Date:
**st: Syntax problems with maximum likelihood (method lf)** - Previous by thread:
**Re: st: RE: Summary statistics table problem** - Next by thread:
**Re: st: Mata and semicolon** - Index(es):

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