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   Thu, 29 Jul 2010 17:14:03 -0400

Thank you again Eric and Martin!

On Wed, Jul 28, 2010 at 10:10 AM, Eric Booth <[email protected]> wrote:
>
> <>
> Yeah, it was a typo, I meant to type "firstyear" instead of "year" in that last line.
>
> Also, you could also use -fillin- (from SSC) to create balanced panels after dropping
> panels that are problematic (start after 2003 & with closure | chow).
>
> cap which fillin
> if _rc ssc install fillin, replace
> fillin oshpd_fac_no year
>
> ~ Eric
>
> ________________________________________
> From: [email protected] [[email protected]] on behalf of Martin Weiss [[email protected]]
> Sent: Wednesday, July 28, 2010 8:48 AM
> To: [email protected]
> Subject: AW: st: Dropping observations and creating a balanced panel
>
> <>
>
> "I am off to try and figure out the duplicates or some similar command."
>
>
>
> You can find the problematic observations thus:
>
> *************
> sysuse nlswork,clear
> bys idcode: gen int number=_N
> su number, mean
> cou if number!=r(max)
> *************
>
>
>
> HTH
> Martin
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Matthew
> Krauchunas
> Gesendet: Mittwoch, 28. Juli 2010 15:27
> An: [email protected]
> Betreff: Re: st: Dropping observations and creating a balanced panel
>
> 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/
>
>
> *
> *   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/

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