Hi Statalisters,
I have a very unbalanced panel data set, composed for a lot of panel and 12 years. I'm interested in "balance" this panel, keeping only the panel tha have information for a set of variables in all the period. How can I do that? Thanks -- CdeB * * 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/ |
.
http://www.stata.com/support/faqs/data/panel.html HTH, Philipp Christian Bustamante wrote: > Hi Statalisters, > > I have a very unbalanced panel data set, composed for a lot of panel > and 12 years. I'm interested in "balance" this panel, keeping only the > panel tha have information for a set of variables in all the period. > How can I do that? > > Thanks > * * 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/ |
Hi and thanks for your response. That's not what I'm looking for. I
will be more explicit. Supose the folliwing data set with each row represents a panel observations for a variable: 1 2 3 4 5 6 7 8 . . 3 4 5 6 7 8 1 2 3 . 5 6 7 8 1 2 3 4 5 6 7 . 1 2 3 4 5 . . . I want to keep only the observations like the first one and drop the others. Bests On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: > . > > http://www.stata.com/support/faqs/data/panel.html > > HTH, > Philipp > > Christian Bustamante wrote: >> >> Hi Statalisters, >> >> I have a very unbalanced panel data set, composed for a lot of panel >> and 12 years. I'm interested in "balance" this panel, keeping only the >> panel tha have information for a set of variables in all the period. >> How can I do that? >> >> Thanks >> > * > * 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/ > -- CdeB * * 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/ |
.
Nick Cox's -dropmiss- may be useful. You may want to check out -findit dropmiss- It seems your panel data-set is in wide format. For most purposes, that's very inconvenient, at best. You may want to -reshape- your data-set to long format. HTH, Philipp Christian Bustamante wrote: > Hi and thanks for your response. That's not what I'm looking for. I > will be more explicit. > Supose the folliwing data set with each row represents a panel > observations for a variable: > > 1 2 3 4 5 6 7 8 > . . 3 4 5 6 7 8 > 1 2 3 . 5 6 7 8 > 1 2 3 4 5 6 7 . > 1 2 3 4 5 . . . > > I want to keep only the observations like the first one and drop the others. > > Bests > > > > On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >> . >> >> http://www.stata.com/support/faqs/data/panel.html >> >> HTH, >> Philipp >> >> Christian Bustamante wrote: >>> Hi Statalisters, >>> >>> I have a very unbalanced panel data set, composed for a lot of panel >>> and 12 years. I'm interested in "balance" this panel, keeping only the >>> panel tha have information for a set of variables in all the period. >>> How can I do that? >>> >>> Thanks >>> >> * >> * 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/ |
That's solve the problem if the data set has all years for all panels,
but it isn't. The data set is about firm's financial information, thus the firms that not reported information before 2000 (for example) doen't have a time period associated to it's id. The same occur with firms that have information since the begining of panel, but in 2003 there isn't data an then a row with 2003 in the year variable for this firm and missing in all other values. I supose that it would be solved creating this "years" with missing data for all firms that hasn't information in this period, but I don't know how to do that. Thanks On Thu, Apr 2, 2009 at 4:09 PM, Philipp Rehm <[hidden email]> wrote: > . > Nick Cox's -dropmiss- may be useful. You may want to check out -findit > dropmiss- > > It seems your panel data-set is in wide format. For most purposes, that's > very inconvenient, at best. You may want to -reshape- your data-set to long > format. > > HTH, > Philipp > > Christian Bustamante wrote: >> >> Hi and thanks for your response. That's not what I'm looking for. I >> will be more explicit. >> Supose the folliwing data set with each row represents a panel >> observations for a variable: >> >> 1 2 3 4 5 6 7 8 >> . . 3 4 5 6 7 8 >> 1 2 3 . 5 6 7 8 >> 1 2 3 4 5 6 7 . >> 1 2 3 4 5 . . . >> >> I want to keep only the observations like the first one and drop the >> others. >> >> Bests >> >> >> >> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >>> >>> . >>> >>> http://www.stata.com/support/faqs/data/panel.html >>> >>> HTH, >>> Philipp >>> >>> Christian Bustamante wrote: >>>> >>>> Hi Statalisters, >>>> >>>> I have a very unbalanced panel data set, composed for a lot of panel >>>> and 12 years. I'm interested in "balance" this panel, keeping only the >>>> panel tha have information for a set of variables in all the period. >>>> How can I do that? >>>> >>>> Thanks >>>> >>> * >>> * 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/ > -- CdeB * * 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/ |
.
How about -tsfill-? In particular: -tsfill, full- Ph Christian Bustamante wrote: > That's solve the problem if the data set has all years for all panels, > but it isn't. The data set is about firm's financial information, thus > the firms that not reported information before 2000 (for example) > doen't have a time period associated to it's id. The same occur with > firms that have information since the begining of panel, but in 2003 > there isn't data an then a row with 2003 in the year variable for this > firm and missing in all other values. > > I supose that it would be solved creating this "years" with missing > data for all firms that hasn't information in this period, but I don't > know how to do that. > > Thanks > > > On Thu, Apr 2, 2009 at 4:09 PM, Philipp Rehm <[hidden email]> wrote: >> . >> Nick Cox's -dropmiss- may be useful. You may want to check out -findit >> dropmiss- >> >> It seems your panel data-set is in wide format. For most purposes, that's >> very inconvenient, at best. You may want to -reshape- your data-set to long >> format. >> >> HTH, >> Philipp >> >> Christian Bustamante wrote: >>> Hi and thanks for your response. That's not what I'm looking for. I >>> will be more explicit. >>> Supose the folliwing data set with each row represents a panel >>> observations for a variable: >>> >>> 1 2 3 4 5 6 7 8 >>> . . 3 4 5 6 7 8 >>> 1 2 3 . 5 6 7 8 >>> 1 2 3 4 5 6 7 . >>> 1 2 3 4 5 . . . >>> >>> I want to keep only the observations like the first one and drop the >>> others. >>> >>> Bests >>> >>> >>> >>> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >>>> . >>>> >>>> http://www.stata.com/support/faqs/data/panel.html >>>> >>>> HTH, >>>> Philipp >>>> >>>> Christian Bustamante wrote: >>>>> Hi Statalisters, >>>>> >>>>> I have a very unbalanced panel data set, composed for a lot of panel >>>>> and 12 years. I'm interested in "balance" this panel, keeping only the >>>>> panel tha have information for a set of variables in all the period. >>>>> How can I do that? >>>>> >>>>> Thanks >>>>> >>>> * >>>> * 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/ |
In reply to this post by Christian Bustamante
<>
You ought to give a much clearer excerpt of your data. If it is really as simple as the one below, use -egen myrowmiss, rowmiss()- and you can easily drop depending on whether the row has any missings by -drop if myrowmiss >0 & !mi(myrowmiss)-. HTH Martin _______________________ ----- Original Message ----- From: "Christian Bustamante" <[hidden email]> To: <[hidden email]> Sent: Thursday, April 02, 2009 10:50 PM Subject: Re: st: How to balance an unbalanced panel data set > Hi and thanks for your response. That's not what I'm looking for. I > will be more explicit. > Supose the folliwing data set with each row represents a panel > observations for a variable: > > 1 2 3 4 5 6 7 8 > . . 3 4 5 6 7 8 > 1 2 3 . 5 6 7 8 > 1 2 3 4 5 6 7 . > 1 2 3 4 5 . . . > > I want to keep only the observations like the first one and drop the > others. > > Bests > > > > On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >> . >> >> http://www.stata.com/support/faqs/data/panel.html >> >> HTH, >> Philipp >> >> Christian Bustamante wrote: >>> >>> Hi Statalisters, >>> >>> I have a very unbalanced panel data set, composed for a lot of panel >>> and 12 years. I'm interested in "balance" this panel, keeping only the >>> panel tha have information for a set of variables in all the period. >>> How can I do that? >>> >>> Thanks >>> >> * >> * 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/ >> > > > > -- > CdeB > > * > * 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/ |
Hi Martin
This is a better example: --------------- | year id var1| |---------------| | 1998 01 . | | 1999 01 . | | 2000 01 34 | | 2001 01 23 | | 2002 01 25 | |---------------| | 1998 02 56 | | 1999 02 45 | | 2000 02 67 | | 2001 02 47 | | 2002 02 . | |---------------| | 1998 03 11 | | 1999 03 13 | | 2000 03 . | | 2001 03 . | | 2002 03 23 | |---------------| | 1998 04 44 | | 1999 04 24 | | 2000 04 33 | | 2001 04 36 | | 2002 04 41 | |---------------| | 1999 05 24 | | 2000 05 35 | | 2002 05 45 | |---------------| In this example I only want the panel with id 04 with data in all the years, and drop the panels 01, 02 and 03 with a missing value in at least one year for var1. I also want to drop the panel 05 with doesn't have values in all years. On Thu, Apr 2, 2009 at 4:37 PM, Martin Weiss <[hidden email]> wrote: > <> > > You ought to give a much clearer excerpt of your data. > > If it is really as simple as the one below, use -egen myrowmiss, rowmiss()- > and you can easily drop depending on whether the row has any missings by > -drop if myrowmiss >0 & !mi(myrowmiss)-. > > > HTH > Martin > _______________________ > ----- Original Message ----- From: "Christian Bustamante" <[hidden email]> > To: <[hidden email]> > Sent: Thursday, April 02, 2009 10:50 PM > Subject: Re: st: How to balance an unbalanced panel data set > > >> Hi and thanks for your response. That's not what I'm looking for. I >> will be more explicit. >> Supose the folliwing data set with each row represents a panel >> observations for a variable: >> >> 1 2 3 4 5 6 7 8 >> . . 3 4 5 6 7 8 >> 1 2 3 . 5 6 7 8 >> 1 2 3 4 5 6 7 . >> 1 2 3 4 5 . . . >> >> I want to keep only the observations like the first one and drop the >> others. >> >> Bests >> >> >> >> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >>> >>> . >>> >>> http://www.stata.com/support/faqs/data/panel.html >>> >>> HTH, >>> Philipp >>> >>> Christian Bustamante wrote: >>>> >>>> Hi Statalisters, >>>> >>>> I have a very unbalanced panel data set, composed for a lot of panel >>>> and 12 years. I'm interested in "balance" this panel, keeping only the >>>> panel tha have information for a set of variables in all the period. >>>> How can I do that? >>>> >>>> Thanks >>>> >>> * >>> * 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/ >>> >> >> >> >> -- >> CdeB >> >> * >> * 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/ > -- CdeB * * 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/ |
In reply to this post by Christian Bustamante
<>
Christian said In this example I only want the panel with id 04 with data in all the years, and drop the panels 01, 02 and 03 with a missing value in at least one year for var1. I also want to drop the panel 05 with doesn't have values in all years. drop if mi(var1) [ which could be if mi(var1, var2, .... varn), but they must be explicitly named) by id: keep if _N == 5 Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html * * 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/ |
In reply to this post by Christian Bustamante
<> So the end result is that you end up with only panel 4? If you throw out observations due to missingness beforehand, that is the inevitable conclusion... ************* clear* inp year id var1 1998 1 . 1999 1 . 2000 1 34 2001 1 23 2002 1 25 1998 2 56 1999 2 45 2000 2 67 2001 2 47 2002 2 . 1998 3 11 1999 3 13 2000 3 . 2001 3 . 2002 3 23 1998 4 44 1999 4 24 2000 4 33 2001 4 36 2002 4 41 1999 5 24 2000 5 35 2002 5 45 end drop if mi(var1) tempvar length bys id (year): gen `length'=_N su `length', mean bys id: drop if `length'!=r(max) ************* HTH Martin -----Ursprüngliche Nachricht----- Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Christian Bustamante Gesendet: Freitag, 3. April 2009 04:15 An: [hidden email] Betreff: Re: st: How to balance an unbalanced panel data set Hi Martin This is a better example: --------------- | year id var1| |---------------| | 1998 01 . | | 1999 01 . | | 2000 01 34 | | 2001 01 23 | | 2002 01 25 | |---------------| | 1998 02 56 | | 1999 02 45 | | 2000 02 67 | | 2001 02 47 | | 2002 02 . | |---------------| | 1998 03 11 | | 1999 03 13 | | 2000 03 . | | 2001 03 . | | 2002 03 23 | |---------------| | 1998 04 44 | | 1999 04 24 | | 2000 04 33 | | 2001 04 36 | | 2002 04 41 | |---------------| | 1999 05 24 | | 2000 05 35 | | 2002 05 45 | |---------------| In this example I only want the panel with id 04 with data in all the years, and drop the panels 01, 02 and 03 with a missing value in at least one year for var1. I also want to drop the panel 05 with doesn't have values in all years. On Thu, Apr 2, 2009 at 4:37 PM, Martin Weiss <[hidden email]> wrote: > <> > > You ought to give a much clearer excerpt of your data. > > If it is really as simple as the one below, use -egen myrowmiss, rowmiss()- > and you can easily drop depending on whether the row has any missings by > -drop if myrowmiss >0 & !mi(myrowmiss)-. > > > HTH > Martin > _______________________ > ----- Original Message ----- From: "Christian Bustamante" <[hidden email]> > To: <[hidden email]> > Sent: Thursday, April 02, 2009 10:50 PM > Subject: Re: st: How to balance an unbalanced panel data set > > >> Hi and thanks for your response. That's not what I'm looking for. I >> will be more explicit. >> Supose the folliwing data set with each row represents a panel >> observations for a variable: >> >> 1 2 3 4 5 6 7 8 >> . . 3 4 5 6 7 8 >> 1 2 3 . 5 6 7 8 >> 1 2 3 4 5 6 7 . >> 1 2 3 4 5 . . . >> >> I want to keep only the observations like the first one and drop the >> others. >> >> Bests >> >> >> >> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >>> >>> . >>> >>> http://www.stata.com/support/faqs/data/panel.html >>> >>> HTH, >>> Philipp >>> >>> Christian Bustamante wrote: >>>> >>>> Hi Statalisters, >>>> >>>> I have a very unbalanced panel data set, composed for a lot of panel >>>> and 12 years. I'm interested in "balance" this panel, keeping only the >>>> panel tha have information for a set of variables in all the period. >>>> How can I do that? >>>> >>>> Thanks >>>> >>> * >>> * 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/ >>> >> >> >> >> -- >> CdeB >> >> * >> * 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/ > -- CdeB * * 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/ |
In reply to this post by Christian Bustamante
Still appears Obs per group: min = 1m. Why?
On Fri, Apr 3, 2009 at 2:18 AM, Martin Weiss <[hidden email]> wrote: > > <> > > So the end result is that you end up with only panel 4? If you throw out > observations due to missingness beforehand, that is the inevitable > conclusion... > > > ************* > clear* > > inp year id var1 > 1998 1 . > 1999 1 . > 2000 1 34 > 2001 1 23 > 2002 1 25 > 1998 2 56 > 1999 2 45 > 2000 2 67 > 2001 2 47 > 2002 2 . > 1998 3 11 > 1999 3 13 > 2000 3 . > 2001 3 . > 2002 3 23 > 1998 4 44 > 1999 4 24 > 2000 4 33 > 2001 4 36 > 2002 4 41 > 1999 5 24 > 2000 5 35 > 2002 5 45 > end > > drop if mi(var1) > > tempvar length > bys id (year): gen `length'=_N > su `length', mean > bys id: drop if `length'!=r(max) > ************* > > > > HTH > Martin > > -----Ursprüngliche Nachricht----- > Von: [hidden email] > [mailto:[hidden email]] Im Auftrag von Christian > Bustamante > Gesendet: Freitag, 3. April 2009 04:15 > An: [hidden email] > Betreff: Re: st: How to balance an unbalanced panel data set > > Hi Martin > This is a better example: > > --------------- > | year id var1| > |---------------| > | 1998 01 . | > | 1999 01 . | > | 2000 01 34 | > | 2001 01 23 | > | 2002 01 25 | > |---------------| > | 1998 02 56 | > | 1999 02 45 | > | 2000 02 67 | > | 2001 02 47 | > | 2002 02 . | > |---------------| > | 1998 03 11 | > | 1999 03 13 | > | 2000 03 . | > | 2001 03 . | > | 2002 03 23 | > |---------------| > | 1998 04 44 | > | 1999 04 24 | > | 2000 04 33 | > | 2001 04 36 | > | 2002 04 41 | > |---------------| > | 1999 05 24 | > | 2000 05 35 | > | 2002 05 45 | > |---------------| > > In this example I only want the panel with id 04 with data in all the > years, and drop the panels 01, 02 and 03 with a missing value in at > least one year for var1. I also want to drop the panel 05 with doesn't > have values in all years. > > On Thu, Apr 2, 2009 at 4:37 PM, Martin Weiss <[hidden email]> wrote: >> <> >> >> You ought to give a much clearer excerpt of your data. >> >> If it is really as simple as the one below, use -egen myrowmiss, > rowmiss()- >> and you can easily drop depending on whether the row has any missings by >> -drop if myrowmiss >0 & !mi(myrowmiss)-. >> >> >> HTH >> Martin >> _______________________ >> ----- Original Message ----- From: "Christian Bustamante" > <[hidden email]> >> To: <[hidden email]> >> Sent: Thursday, April 02, 2009 10:50 PM >> Subject: Re: st: How to balance an unbalanced panel data set >> >> >>> Hi and thanks for your response. That's not what I'm looking for. I >>> will be more explicit. >>> Supose the folliwing data set with each row represents a panel >>> observations for a variable: >>> >>> 1 2 3 4 5 6 7 8 >>> . . 3 4 5 6 7 8 >>> 1 2 3 . 5 6 7 8 >>> 1 2 3 4 5 6 7 . >>> 1 2 3 4 5 . . . >>> >>> I want to keep only the observations like the first one and drop the >>> others. >>> >>> Bests >>> >>> >>> >>> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> wrote: >>>> >>>> . >>>> >>>> http://www.stata.com/support/faqs/data/panel.html >>>> >>>> HTH, >>>> Philipp >>>> >>>> Christian Bustamante wrote: >>>>> >>>>> Hi Statalisters, >>>>> >>>>> I have a very unbalanced panel data set, composed for a lot of panel >>>>> and 12 years. I'm interested in "balance" this panel, keeping only the >>>>> panel tha have information for a set of variables in all the period. >>>>> How can I do that? >>>>> >>>>> Thanks >>>>> >>>> * >>>> * 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/ >>>> >>> >>> >>> >>> -- >>> CdeB >>> >>> * >>> * 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/ >> > > > > -- > CdeB > > * > * 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/ > -- CdeB * * 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/ |
<>
What is your question exactly? HTH Martin _______________________ ----- Original Message ----- From: "Christian Bustamante" <[hidden email]> To: <[hidden email]> Sent: Saturday, April 04, 2009 9:37 PM Subject: Re: st: How to balance an unbalanced panel data set > Still appears Obs per group: min = 1m. Why? > > On Fri, Apr 3, 2009 at 2:18 AM, Martin Weiss <[hidden email]> wrote: >> >> <> >> >> So the end result is that you end up with only panel 4? If you throw out >> observations due to missingness beforehand, that is the inevitable >> conclusion... >> >> >> ************* >> clear* >> >> inp year id var1 >> 1998 1 . >> 1999 1 . >> 2000 1 34 >> 2001 1 23 >> 2002 1 25 >> 1998 2 56 >> 1999 2 45 >> 2000 2 67 >> 2001 2 47 >> 2002 2 . >> 1998 3 11 >> 1999 3 13 >> 2000 3 . >> 2001 3 . >> 2002 3 23 >> 1998 4 44 >> 1999 4 24 >> 2000 4 33 >> 2001 4 36 >> 2002 4 41 >> 1999 5 24 >> 2000 5 35 >> 2002 5 45 >> end >> >> drop if mi(var1) >> >> tempvar length >> bys id (year): gen `length'=_N >> su `length', mean >> bys id: drop if `length'!=r(max) >> ************* >> >> >> >> HTH >> Martin >> >> -----Ursprüngliche Nachricht----- >> Von: [hidden email] >> [mailto:[hidden email]] Im Auftrag von Christian >> Bustamante >> Gesendet: Freitag, 3. April 2009 04:15 >> An: [hidden email] >> Betreff: Re: st: How to balance an unbalanced panel data set >> >> Hi Martin >> This is a better example: >> >> --------------- >> | year id var1| >> |---------------| >> | 1998 01 . | >> | 1999 01 . | >> | 2000 01 34 | >> | 2001 01 23 | >> | 2002 01 25 | >> |---------------| >> | 1998 02 56 | >> | 1999 02 45 | >> | 2000 02 67 | >> | 2001 02 47 | >> | 2002 02 . | >> |---------------| >> | 1998 03 11 | >> | 1999 03 13 | >> | 2000 03 . | >> | 2001 03 . | >> | 2002 03 23 | >> |---------------| >> | 1998 04 44 | >> | 1999 04 24 | >> | 2000 04 33 | >> | 2001 04 36 | >> | 2002 04 41 | >> |---------------| >> | 1999 05 24 | >> | 2000 05 35 | >> | 2002 05 45 | >> |---------------| >> >> In this example I only want the panel with id 04 with data in all the >> years, and drop the panels 01, 02 and 03 with a missing value in at >> least one year for var1. I also want to drop the panel 05 with doesn't >> have values in all years. >> >> On Thu, Apr 2, 2009 at 4:37 PM, Martin Weiss <[hidden email]> >> wrote: >>> <> >>> >>> You ought to give a much clearer excerpt of your data. >>> >>> If it is really as simple as the one below, use -egen myrowmiss, >> rowmiss()- >>> and you can easily drop depending on whether the row has any missings by >>> -drop if myrowmiss >0 & !mi(myrowmiss)-. >>> >>> >>> HTH >>> Martin >>> _______________________ >>> ----- Original Message ----- From: "Christian Bustamante" >> <[hidden email]> >>> To: <[hidden email]> >>> Sent: Thursday, April 02, 2009 10:50 PM >>> Subject: Re: st: How to balance an unbalanced panel data set >>> >>> >>>> Hi and thanks for your response. That's not what I'm looking for. I >>>> will be more explicit. >>>> Supose the folliwing data set with each row represents a panel >>>> observations for a variable: >>>> >>>> 1 2 3 4 5 6 7 8 >>>> . . 3 4 5 6 7 8 >>>> 1 2 3 . 5 6 7 8 >>>> 1 2 3 4 5 6 7 . >>>> 1 2 3 4 5 . . . >>>> >>>> I want to keep only the observations like the first one and drop the >>>> others. >>>> >>>> Bests >>>> >>>> >>>> >>>> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> >>>> wrote: >>>>> >>>>> . >>>>> >>>>> http://www.stata.com/support/faqs/data/panel.html >>>>> >>>>> HTH, >>>>> Philipp >>>>> >>>>> Christian Bustamante wrote: >>>>>> >>>>>> Hi Statalisters, >>>>>> >>>>>> I have a very unbalanced panel data set, composed for a lot of panel >>>>>> and 12 years. I'm interested in "balance" this panel, keeping only >>>>>> the >>>>>> panel tha have information for a set of variables in all the period. >>>>>> How can I do that? >>>>>> >>>>>> Thanks >>>>>> >>>>> * >>>>> * 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/ >>>>> >>>> >>>> >>>> >>>> -- >>>> CdeB >>>> >>>> * >>>> * 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/ >>> >> >> >> >> -- >> CdeB >> >> * >> * 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/ >> > > > > -- > CdeB > > * > * 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/ |
If i'm not wrong, when the panel is balanced, a regression should have
the same number of observations in each group. After doing that you and Kit suggest me, it still appears the minimum observations per group equal to 1. Why happens it if with your process the panel is strongly balanced. CB On Sat, Apr 4, 2009 at 2:40 PM, Martin Weiss <[hidden email]> wrote: > <> > > What is your question exactly? > > HTH > Martin > _______________________ > ----- Original Message ----- From: "Christian Bustamante" <[hidden email]> > To: <[hidden email]> > Sent: Saturday, April 04, 2009 9:37 PM > Subject: Re: st: How to balance an unbalanced panel data set > > >> Still appears Obs per group: min = 1m. Why? >> >> On Fri, Apr 3, 2009 at 2:18 AM, Martin Weiss <[hidden email]> wrote: >>> >>> <> >>> >>> So the end result is that you end up with only panel 4? If you throw out >>> observations due to missingness beforehand, that is the inevitable >>> conclusion... >>> >>> >>> ************* >>> clear* >>> >>> inp year id var1 >>> 1998 1 . >>> 1999 1 . >>> 2000 1 34 >>> 2001 1 23 >>> 2002 1 25 >>> 1998 2 56 >>> 1999 2 45 >>> 2000 2 67 >>> 2001 2 47 >>> 2002 2 . >>> 1998 3 11 >>> 1999 3 13 >>> 2000 3 . >>> 2001 3 . >>> 2002 3 23 >>> 1998 4 44 >>> 1999 4 24 >>> 2000 4 33 >>> 2001 4 36 >>> 2002 4 41 >>> 1999 5 24 >>> 2000 5 35 >>> 2002 5 45 >>> end >>> >>> drop if mi(var1) >>> >>> tempvar length >>> bys id (year): gen `length'=_N >>> su `length', mean >>> bys id: drop if `length'!=r(max) >>> ************* >>> >>> >>> >>> HTH >>> Martin >>> >>> -----Ursprüngliche Nachricht----- >>> Von: [hidden email] >>> [mailto:[hidden email]] Im Auftrag von Christian >>> Bustamante >>> Gesendet: Freitag, 3. April 2009 04:15 >>> An: [hidden email] >>> Betreff: Re: st: How to balance an unbalanced panel data set >>> >>> Hi Martin >>> This is a better example: >>> >>> --------------- >>> | year id var1| >>> |---------------| >>> | 1998 01 . | >>> | 1999 01 . | >>> | 2000 01 34 | >>> | 2001 01 23 | >>> | 2002 01 25 | >>> |---------------| >>> | 1998 02 56 | >>> | 1999 02 45 | >>> | 2000 02 67 | >>> | 2001 02 47 | >>> | 2002 02 . | >>> |---------------| >>> | 1998 03 11 | >>> | 1999 03 13 | >>> | 2000 03 . | >>> | 2001 03 . | >>> | 2002 03 23 | >>> |---------------| >>> | 1998 04 44 | >>> | 1999 04 24 | >>> | 2000 04 33 | >>> | 2001 04 36 | >>> | 2002 04 41 | >>> |---------------| >>> | 1999 05 24 | >>> | 2000 05 35 | >>> | 2002 05 45 | >>> |---------------| >>> >>> In this example I only want the panel with id 04 with data in all the >>> years, and drop the panels 01, 02 and 03 with a missing value in at >>> least one year for var1. I also want to drop the panel 05 with doesn't >>> have values in all years. >>> >>> On Thu, Apr 2, 2009 at 4:37 PM, Martin Weiss <[hidden email]> >>> wrote: >>>> >>>> <> >>>> >>>> You ought to give a much clearer excerpt of your data. >>>> >>>> If it is really as simple as the one below, use -egen myrowmiss, >>> >>> rowmiss()- >>>> >>>> and you can easily drop depending on whether the row has any missings by >>>> -drop if myrowmiss >0 & !mi(myrowmiss)-. >>>> >>>> >>>> HTH >>>> Martin >>>> _______________________ >>>> ----- Original Message ----- From: "Christian Bustamante" >>> >>> <[hidden email]> >>>> >>>> To: <[hidden email]> >>>> Sent: Thursday, April 02, 2009 10:50 PM >>>> Subject: Re: st: How to balance an unbalanced panel data set >>>> >>>> >>>>> Hi and thanks for your response. That's not what I'm looking for. I >>>>> will be more explicit. >>>>> Supose the folliwing data set with each row represents a panel >>>>> observations for a variable: >>>>> >>>>> 1 2 3 4 5 6 7 8 >>>>> . . 3 4 5 6 7 8 >>>>> 1 2 3 . 5 6 7 8 >>>>> 1 2 3 4 5 6 7 . >>>>> 1 2 3 4 5 . . . >>>>> >>>>> I want to keep only the observations like the first one and drop the >>>>> others. >>>>> >>>>> Bests >>>>> >>>>> >>>>> >>>>> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> >>>>> wrote: >>>>>> >>>>>> . >>>>>> >>>>>> http://www.stata.com/support/faqs/data/panel.html >>>>>> >>>>>> HTH, >>>>>> Philipp >>>>>> >>>>>> Christian Bustamante wrote: >>>>>>> >>>>>>> Hi Statalisters, >>>>>>> >>>>>>> I have a very unbalanced panel data set, composed for a lot of panel >>>>>>> and 12 years. I'm interested in "balance" this panel, keeping only >>>>>>> the >>>>>>> panel tha have information for a set of variables in all the period. >>>>>>> How can I do that? >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>> * >>>>>> * 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/ >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> CdeB >>>>> >>>>> * >>>>> * 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/ >>>> >>> >>> >>> >>> -- >>> CdeB >>> >>> * >>> * 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/ >>> >> >> >> >> -- >> CdeB >> >> * >> * 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/ > -- CdeB * * 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/ |
<>
What does -xtdescribe- give you? Which xt command are you running for your regression? HTH Martin _______________________ ----- Original Message ----- From: "Christian Bustamante" <[hidden email]> To: <[hidden email]> Sent: Saturday, April 04, 2009 10:21 PM Subject: Re: st: How to balance an unbalanced panel data set > If i'm not wrong, when the panel is balanced, a regression should have > the same number of observations in each group. After doing that you > and Kit suggest me, it still appears the minimum observations per > group equal to 1. Why happens it if with your process the panel is > strongly balanced. > > > CB > > On Sat, Apr 4, 2009 at 2:40 PM, Martin Weiss <[hidden email]> wrote: >> <> >> >> What is your question exactly? >> >> HTH >> Martin >> _______________________ >> ----- Original Message ----- From: "Christian Bustamante" >> <[hidden email]> >> To: <[hidden email]> >> Sent: Saturday, April 04, 2009 9:37 PM >> Subject: Re: st: How to balance an unbalanced panel data set >> >> >>> Still appears Obs per group: min = 1m. Why? >>> >>> On Fri, Apr 3, 2009 at 2:18 AM, Martin Weiss <[hidden email]> >>> wrote: >>>> >>>> <> >>>> >>>> So the end result is that you end up with only panel 4? If you throw >>>> out >>>> observations due to missingness beforehand, that is the inevitable >>>> conclusion... >>>> >>>> >>>> ************* >>>> clear* >>>> >>>> inp year id var1 >>>> 1998 1 . >>>> 1999 1 . >>>> 2000 1 34 >>>> 2001 1 23 >>>> 2002 1 25 >>>> 1998 2 56 >>>> 1999 2 45 >>>> 2000 2 67 >>>> 2001 2 47 >>>> 2002 2 . >>>> 1998 3 11 >>>> 1999 3 13 >>>> 2000 3 . >>>> 2001 3 . >>>> 2002 3 23 >>>> 1998 4 44 >>>> 1999 4 24 >>>> 2000 4 33 >>>> 2001 4 36 >>>> 2002 4 41 >>>> 1999 5 24 >>>> 2000 5 35 >>>> 2002 5 45 >>>> end >>>> >>>> drop if mi(var1) >>>> >>>> tempvar length >>>> bys id (year): gen `length'=_N >>>> su `length', mean >>>> bys id: drop if `length'!=r(max) >>>> ************* >>>> >>>> >>>> >>>> HTH >>>> Martin >>>> >>>> -----Ursprüngliche Nachricht----- >>>> Von: [hidden email] >>>> [mailto:[hidden email]] Im Auftrag von Christian >>>> Bustamante >>>> Gesendet: Freitag, 3. April 2009 04:15 >>>> An: [hidden email] >>>> Betreff: Re: st: How to balance an unbalanced panel data set >>>> >>>> Hi Martin >>>> This is a better example: >>>> >>>> --------------- >>>> | year id var1| >>>> |---------------| >>>> | 1998 01 . | >>>> | 1999 01 . | >>>> | 2000 01 34 | >>>> | 2001 01 23 | >>>> | 2002 01 25 | >>>> |---------------| >>>> | 1998 02 56 | >>>> | 1999 02 45 | >>>> | 2000 02 67 | >>>> | 2001 02 47 | >>>> | 2002 02 . | >>>> |---------------| >>>> | 1998 03 11 | >>>> | 1999 03 13 | >>>> | 2000 03 . | >>>> | 2001 03 . | >>>> | 2002 03 23 | >>>> |---------------| >>>> | 1998 04 44 | >>>> | 1999 04 24 | >>>> | 2000 04 33 | >>>> | 2001 04 36 | >>>> | 2002 04 41 | >>>> |---------------| >>>> | 1999 05 24 | >>>> | 2000 05 35 | >>>> | 2002 05 45 | >>>> |---------------| >>>> >>>> In this example I only want the panel with id 04 with data in all the >>>> years, and drop the panels 01, 02 and 03 with a missing value in at >>>> least one year for var1. I also want to drop the panel 05 with doesn't >>>> have values in all years. >>>> >>>> On Thu, Apr 2, 2009 at 4:37 PM, Martin Weiss <[hidden email]> >>>> wrote: >>>>> >>>>> <> >>>>> >>>>> You ought to give a much clearer excerpt of your data. >>>>> >>>>> If it is really as simple as the one below, use -egen myrowmiss, >>>> >>>> rowmiss()- >>>>> >>>>> and you can easily drop depending on whether the row has any missings >>>>> by >>>>> -drop if myrowmiss >0 & !mi(myrowmiss)-. >>>>> >>>>> >>>>> HTH >>>>> Martin >>>>> _______________________ >>>>> ----- Original Message ----- From: "Christian Bustamante" >>>> >>>> <[hidden email]> >>>>> >>>>> To: <[hidden email]> >>>>> Sent: Thursday, April 02, 2009 10:50 PM >>>>> Subject: Re: st: How to balance an unbalanced panel data set >>>>> >>>>> >>>>>> Hi and thanks for your response. That's not what I'm looking for. I >>>>>> will be more explicit. >>>>>> Supose the folliwing data set with each row represents a panel >>>>>> observations for a variable: >>>>>> >>>>>> 1 2 3 4 5 6 7 8 >>>>>> . . 3 4 5 6 7 8 >>>>>> 1 2 3 . 5 6 7 8 >>>>>> 1 2 3 4 5 6 7 . >>>>>> 1 2 3 4 5 . . . >>>>>> >>>>>> I want to keep only the observations like the first one and drop the >>>>>> others. >>>>>> >>>>>> Bests >>>>>> >>>>>> >>>>>> >>>>>> On Thu, Apr 2, 2009 at 3:31 PM, Philipp Rehm <[hidden email]> >>>>>> wrote: >>>>>>> >>>>>>> . >>>>>>> >>>>>>> http://www.stata.com/support/faqs/data/panel.html >>>>>>> >>>>>>> HTH, >>>>>>> Philipp >>>>>>> >>>>>>> Christian Bustamante wrote: >>>>>>>> >>>>>>>> Hi Statalisters, >>>>>>>> >>>>>>>> I have a very unbalanced panel data set, composed for a lot of >>>>>>>> panel >>>>>>>> and 12 years. I'm interested in "balance" this panel, keeping only >>>>>>>> the >>>>>>>> panel tha have information for a set of variables in all the >>>>>>>> period. >>>>>>>> How can I do that? >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>> * >>>>>>> * 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/ >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> CdeB >>>>>> >>>>>> * >>>>>> * 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/ >>>>> >>>> >>>> >>>> >>>> -- >>>> CdeB >>>> >>>> * >>>> * 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/ >>>> >>> >>> >>> >>> -- >>> CdeB >>> >>> * >>> * 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/ >> > > > > -- > CdeB > > * > * 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/ |
Free forum by Nabble | Edit this page |