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
Nick Cox <[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 08:28:27 +0100
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/