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: Delete companies based on observations
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Delete companies based on observations
Date
Wed, 13 Nov 2013 10:08:14 +0000
Various errors here:
1. -drop- doesn't support a -by()- option: if it did, that would be documented.
2. There is no -count- function in Stata. Perhaps you mean the -count-
command. (-egen- supports a -count()- function, here meaning
(confusingly) an -egen- function, not a Stata function.)
3. _n only ever refers to observation identifiers in sequence; you want _N.
4. -comnam[_n]- is the current value of -comnam-, not its frequency of
occurrence.
That said,
bysort comnam : drop if _N <= 13
is what you want.
Nick
[email protected]
Mark Krap
> I need to delete all companies of which I have equal or less
> than 13 observations. I already tried the following commands, without the
> desired result.
>
> drop if _n<=13, by(comnam)
>
> drop if comnam[_n]<=13
>
> I assume that the count funtion in Stata can help me to delete these
> companies, but I do not know how to incorporate this in a command in order
> to do the deletions.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/