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: panel data-dropping all observations for the identifier when certain variable value is missing


From   Sabrina Helmut <[email protected]>
To   <[email protected]>
Subject   RE: st: panel data-dropping all observations for the identifier when certain variable value is missing
Date   Wed, 6 Jul 2011 12:11:39 +0200

Nick,

thank you very much so far. There is only one thing I did probably not describe enough. There are observations for all firms/IDs for the years 2004-2010 irrespective of whether there is data for the certain observation (. if missing). How should I rearrange your commands then? Furthermore I do not only have years but complete dates like 31dec2008.
Thanks
-----------------------------------------
> Date: Wed, 6 Jul 2011 08:28:27 +0100
> Subject: Re: st: panel data-dropping all observations for the identifier when certain variable value is missing
> From: [email protected]
> To: [email protected]
>
> bysort firmid (offdate) : drop if offdate[_N] < 2008
>
> bysort firmid (offdate) : gen byte islast = _n == _N
>
> list firmid offdate if islast
>
> See also
>
> SJ-2-1 pr0004 . . . . . . . . . . Speaking Stata: How to move step by: step
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
> Q1/02 SJ 2(1):86--102 (no commands)
> explains the use of the by varlist : construct to tackle
> a variety of problems with group structure, ranging from
> simple calculations for each of several groups to more
> advanced manipulations that use the built-in _n and _N
>
> Nick
>
> On Wed, Jul 6, 2011 at 1:07 AM, Sabrina Helmut <[email protected]> wrote:
>
> > I have firm-year observations for the years 2003-2010. For cases where the last value for the variable <offdate>, which is a variable containing dates, is older than a
> > date in 2008 (so date in 2007, 2006,...) then stata shall drop the firm/identifier at all, so for
> > every year. Then, I want stata to show me for every firm/identifier the last entry for the variable <offdate>, which could then either be a date in 2008, 2009 or 2010. Which commands could help me doing this?
> *
> * 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/
 		 	   		  
*
*   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