Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: counting


From   Christopher F Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: counting
Date   Sat, 7 Feb 2004 08:25:58 -0500

On Feb 7, 2004, at 2:33 AM, Amit wrote:

Suppose I have 5 states and I want to count the number of children in each
state. How can I do this without generating a new variable. If I do

by state: count if child==1

then r(N) only stores the last state's result.
Thanks.
tabstat child, stat(N) by(state)

Not knowing more about your data, I don't know if this will actually do what you want. But some variation on it should. For instance, if your observations are on counties that are part of states, and each county has a variable recording the number of school-age children, then aggregating to the state level would be done with stat(sum). If you Read The Fine Manual (or even the on-line help) you may find it quite useful in this regard.

Kit



*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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   |   What's new   |   Site index