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: Dropping observations and creating a balanced panel
From
Eric Booth <[email protected]>
To
"<[email protected]>" <[email protected]>
Subject
Re: st: Dropping observations and creating a balanced panel
Date
Wed, 28 Jul 2010 01:53:49 +0000
<>
Note: I added facility 206010741 to your example data:
*********!
clear
inp double(oshpd_fac_no) year chow closure
206010734 2002 0 0
206010734 2003 0 0
206010734 2004 0 0
206010734 2006 0 0
206010734 2006 1 0
206010734 2008 0 0
206010744 2002 0 0
206010744 2003 0 0
206010744 2004 0 0
206010744 2007 0 0
206010744 2008 0 0
206010747 2002 0 0
206010747 2003 0 0
206010747 2004 0 0
206010747 2006 0 0
206010747 2007 0 0
206010747 2008 0 0
206010741 2007 0 0
206010741 2004 0 0
206010741 2005 0 0
206010741 2006 0 0
end
** 1. drop all the observations in each of the panels if there was a chow or closure**
bys oshpd_fac_no: egen any_chow = max(chow)
bys oshpd_fac_no: egen any_closure = max(closure)
drop if 1==any_closure | 1==any_chow
**2. drop if I have all nursing homes that opened after 2003 **
bys oshpd_fac_no: egen firstyear = min(year)
drop if year>2003 & !mi(year)
*********!
~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
On Jul 27, 2010, at 4:52 PM, Matthew Krauchunas wrote:
> Hello,
>
> I am studying nursing homes (2002-2004 & 2006-2008) and I have a two
> part problem that I need to solve in order to create a balanced panel.
> First, I have nursing homes that have closed or changed ownership
> (chow) during my study period. I need to drop all the observations
> in each of the panels (panel identifier is the oshpd_fac_no) if there
> was a chow or closure? Second, I have nursing homes that opened after
> 2003 and therefore I would not have all the observations for these
> panels. How can I identify and remove these panels as well? Does
> anyone have any ideas?
>
>
> oshpd_fac_no year chow closure
> 206010734 2002 0 0
> 206010734 2003 0 0
> 206010734 2004 0 0
> 206010734 2006 0 0
> 206010734 2006 1 0
> 206010734 2008 0 0
> 206010744 2002 0 0
> 206010744 2003 0 0
> 206010744 2004 0 0
> 206010744 2007 0 0
> 206010744 2008 0 0
> 206010747 2002 0 0
> 206010747 2003 0 0
> 206010747 2004 0 0
> 206010747 2006 0 0
> 206010747 2007 0 0
> 206010747 2008 0 0
>
> Thank you,
> Matt
> *
*
* 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/