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: Continues panel data
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Continues panel data
Date
Tue, 15 Oct 2013 15:39:20 +0100
There are various ways to do this, depending on your details.
The simplest is where an ideal panel includes say 10 annual values in which case
bysort firmid : drop if _N < 10
removes incomplete panels. Modify for "any value of 10".
Another is where panels may start and end in different years but gaps
are not acceptable.
bysort firmid (year) : gen diff = cond(_n == 1, 1, year - year[_n-1])
calculates a value that should always be 1 and
bysort firmid (diff) : drop if diff[_N] > 1
will drop panels with any values of 2 or more.
If neither matches your exact situation, please spell out what it is.
See also
http://www.stata.com/support/faqs/data-management/identifying-runs-of-consecutive-observations/
Nick
[email protected]
On 15 October 2013 13:46, Ozgur Ozdemir <[email protected]> wrote:
> Hi,
>
> I have a panel data (firm Id, year, sales etc), but would like to remove if there are any gaps for a given firm. e.g If a firm does have a record in 2000, and 2002, but not in 2001, I would like to remove it,.
>
> Is there any way of doing this in Stata please?
>
> thanks, Ozgur
> *
> * 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/
*
* 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/