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 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]

Re: st: summarizing by more than one grouping variable


From   Eric Booth <eric.a.booth@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: summarizing by more than one grouping variable
Date   Tue, 27 Mar 2012 15:25:29 -0500

<>

Here's some examples:
*********
webuse lbw, clear

*1.
bys race smoke: su age

*2.
tab race smoke, summarize(age) mean

*3.
preserve
collapse (mean) age, by(race smoke)
list
restore
*********

- Eric

__
Eric A. Booth
Public Policy Research Institute 
Texas A&M University
ebooth@ppri.tamu.edu
+979.845.6754

On Mar 27, 2012, at 2:19 PM, Lars Folkestad wrote:

> I cannot see my way out of this. There is probably a simple solution.
> 
> I want to summarize my data using two fx sex and type.
> 
> Normally i would use:
> by type, sort: summarize var1, d
> 
> To summarize the variable var1 for each type (or group if you like).
> 
> I would like to see the mean for type1 and female sex, and type1 and male sex and type2 and female sex and type2 male sex.
> 
> lars
> 
> *
> *   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