Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: RE: multiple means by state


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: multiple means by state
Date   Wed, 16 Feb 2011 18:51:06 +0000

No need to do either. For example,  

sysuse census
tabstat pop*, by(state) s(mean)

gives you a table. In census.dta, there is just one observation for each state, but the principle applies to blocks of observations too. 

With counties, you might want to apply weights too, and -tabstat- supports fweights and aweights. 

Nick 
[email protected] 

Millimet, Daniel

1.  create a loop using foreach after defining the 50 variables in a local such as -local vars "x1 x2 ... x50"

2.  just collapse the data and create state-level means and then summarize

	collapse (mean) x1 x2 ... x50, by(state)

    is the syntax I believe.

Jared JS Olesen

I've got county level data on many variables, also coded by state.  I'd
like Stata to report the mean of each US state on nine of those variables
using one command... that is, without typing out 50 separate commands for
each separate variable.  Please help!


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index