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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Collapse and aggregation


From   Neil Shephard <nshephard@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Collapse and aggregation
Date   Mon, 20 Sep 2010 12:43:26 +0000

On Mon, Sep 20, 2010 at 12:37 PM, Santosh Kumar <santosh.uh@gmail.com> wrote:
> Dear all.
>
>  I have individual level data, nested in year, county, and state. for eg: in
>  states, there are many counties and in counties, there are many years and or
>  each years there are many individuals.
>
>   I want to aggregate this data to county and year level, but also want to
>  keep the statecode or statename in order to identify which county belongs to
>  which state.
>
>  How can I use "collapse" command to aggregate in such manner or please
> advise any other different  way to get to this. Keeping the state name or
>  code is crucial for analysis.
>
>  Do appreciate y help.

Well you've identified the correct command, which is -collapse-, but
you missed the -by()- option to this command, see -man collapse- for
more details, but something like....

collapse [how you want to summarise the data], by(statecode year)

Neil


-- 
"One should as a rule, respect public opinion in so far as is
necessary to avoid starvation and to keep out of prison, but anything
that goes beyond this is voluntary submission to an unnecessary
tyranny, and is likely to interfere with happiness in all kinds of
ways..." - Bertrand Russell

Email - nshephard@gmail.com
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/

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