Statalist


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

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


From   Even Bergseng <even.bergseng@umb.no>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   SV: st: creating a balanced panel from an unbalanced panel
Date   Fri, 28 Mar 2008 20:34:26 +0100

Or something like:

tempvar panel
egen panel=count(1), by(ID)
gen balance=1 if panel==11


regards,
Even

________________________________________
Fra: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] p&#229; vegne av Vladimir Vakhitov [vvakhitov@gmail.com]
Sendt: 28. mars 2008 20:20
Til: statalist@hsphsun2.harvard.edu
Emne: Re: st: creating a balanced panel from an unbalanced panel

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 <miahpage@gmail.com>:
> Dear Statalist,
>
>  I hope this question is not too remedial.
>
>  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.
>
>  Any help would be greatly appreciated.
>
>  Thanks,
>  Jeremy
>  *
>  *   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
vvakhitov@gmail.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index