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]

Re: st: Collapse and aggregation


From   Neil Shephard <[email protected]>
To   [email protected]
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 <[email protected]> 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 - [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index