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: Dropping observations and creating a balanced panel


From   Matthew Krauchunas <[email protected]>
To   [email protected]
Subject   Re: st: Dropping observations and creating a balanced panel
Date   Wed, 28 Jul 2010 09:27:21 -0400

Hi Eric,

I had to tweak the code a little bit, but you got me 95% of the way there!

drop if firstyear>2002 & !mi(year)

instead of drop if year>2003 & !mi(year)

My only problem now is that I would expect a balanced panel (i.e., one
divisible by 6), but that is not the case as I have 3,971 observations
remaining.  Also, it will not let me xtset the data.  Instead it gives
me a "repeated time values within panel error."  I am off to try and
figure out the duplicates or some similar command.

Thanks,
Matt

On Tue, Jul 27, 2010 at 9:53 PM, Eric Booth <[email protected]> wrote:
> <>
>
> 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/
>

*
*   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