Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: deleting observations in panel


From   Gregor Franz <[email protected]>
To   [email protected]
Subject   st: deleting observations in panel
Date   Sun, 11 Dec 2005 04:12:28 -0800

Hello List,

As usual I tried to first find information on how to do this elsewhere but was unable to find it. This seems like a fairly easy problem, but it eludes me.

I have an unbalanced panel and would like to delete all the observations for which I don't have the whole date range.

year panelid x
1 1 5
2 1 3
3 1 4
1 2 7
3 2 4

In this example I would like to delete panelid 2. So that in the end I have data for every possible year for every panelid. I tried to drop if the sum of the years is not equal to the sum of all the 6 years I have data for (1998 to 2003), but that just left me with the last year of my data.
I used bysort panelid: drop if sum(year) ~= 12003

Any help would be appreciated.

Thank you,

Gregor
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index