Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: creating a balanced panel from an unbalanced panel


From   "Jeremy Page" <[email protected]>
To   [email protected]
Subject   Re: st: creating a balanced panel from an unbalanced panel
Date   Fri, 28 Mar 2008 16:48:53 -0400

Evan, Vladimir and Austin,

Thank you for all your help.  I really appreciate a forum such as this
where I can improve my stata programing and expand my statistical
knowledge.

Best,
Jeremy

On Fri, Mar 28, 2008 at 4:37 PM, Vladimir Vakhitov <[email protected]> wrote:
> Thank you, Austin, for correcting me. It should be _N indeed.
>  Vladimir
>
>
>  2008/3/28, Austin Nichols <[email protected]>:
>
>
> > Vladimir Vakhitov <[email protected]> and Jeremy Page <[email protected]>:
>  >  The solution below does not give the desired result, but substitute _N
>  >  for _n and it does.  Or in one:
>  >   bys id: g balanced = (_N==7)
>  >
>  >  However, observations may exist and yet contain missing values and
>  >  therefore be excluded from the regression.  Thus you need something
>  >  more like
>  >   qui xtreg y x, i(id) fe
>  >   g ok=e(sample)
>  >   egen sumok=total(ok), by(id)
>  >   su sumok, meanonly
>  >   g allok=(sumok==r(max))
>  >   xtreg y x if allok==1, i(id) fe
>  >
>  >
>  >  On Fri, Mar 28, 2008 at 3:20 PM, Vladimir Vakhitov <[email protected]> wrote:
>  >  > Hi Jeremy,
>  >  >
>  >  >  I would use a simple trick (ID is your panel variable):
>  >  >
>  >  >  tempvar q
>  >  >  bysort id: gen `q' = _n
>  >  >  gen byte balanced = 0
>  >  >  replace balanced = 1 if `q'==7
>  >  >
>  >  >  Vladimir.
>  >  >
>  >  >  2008/3/28, Jeremy Page <[email protected]>:
>  >
>  > >  >  I have an unbalanced panel of seven period and I would like to be able
>  >  >  >  to make a subset of a balanced panel.  I have created dummy variables
>  >  >  >  (T1-T7) for each of the time periods as well as a continuous variable
>  >  >  >  labeled time (1-7).  I would like to create another dummy variable to
>  >  >  >  use in the "if" qualifier of a regression which would be "balanced=1"
>  >  >  >  if there are observations in all 7 periods.
>  >
>  > *
>  >  *   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/
>  >
>
>
>
> --
>  __________________
>  Volodymyr Vakhitov
>  [email protected]
>  *
>
>
> *   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/
>
*
*   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