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: Continues panel data


From   Ozgur Ozdemir <[email protected]>
To   Stata <[email protected]>
Subject   RE: st: Continues panel data
Date   Tue, 15 Oct 2013 15:19:13 +0000

Hi Nick,

Data might start in any year but needs to be continuous until the last year. so I believe I sohuld use 

> bysort firmid (year) : gen diff = cond(_n == 1, 1, year - year[_n-1])

am I right.

However, i did not get the difference between above and below:

> bysort firmid (diff) : drop if diff[_N]> 1

Can you clarify please ?

kind regards
Ozgur Ozdemir



----------------------------------------
> Date: Tue, 15 Oct 2013 15:39:20 +0100
> Subject: Re: st: Continues panel data
> From: [email protected]
> To: [email protected]
>
> 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/ 		 	   		  
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index