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: St: collapse by _N
From
Chris Parker <[email protected]>
To
[email protected]
Subject
Re: st: St: collapse by _N
Date
Wed, 20 Oct 2010 12:17:07 +0530
Hi Ric,
You could count the observations in each geocode, then drop if there
are too few observations then collapse.
bysort geocode: gen numobs=_N
drop if numobs < 20
collapse varlist, by(geocode)
Would that work for your purposes?
Chris
Chris Parker
________________________________
PhD Candidate | Management Science & Operations
London Business School | Regent's Park | London NW1 4SA | United Kingdom
Direct line +44 (0)20 7000 8816 | Email [email protected]
On Wed, Oct 20, 2010 at 12:05 PM, Eric Uslaner <[email protected]> wrote:
>
> Greetings,
>
> I have a survey data set with respondents geocoded. I want to collapse the data set to the geocode level, so the simple command would be:
>
> collapse varlist,by(geocode)
>
> However some geocodes barely have any respondents and any collapsed data would be unreliable. Is there a straightforward way to collapse only if the number of respondents is > 20 (e.g.)?
>
> Many thanks,
>
> Ric
>
>
>
>
> *
> * 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/
>
> ______________________________________________________________________
>
> This email has been scanned by the MessageLabs Email Security System
> on behalf of the London Business School community.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
*
* 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/