Thanks for the immediate response, that's definitely much quicker than
my first solution! Using
bysort panel_identifier: egen want = total(binvar)
did the trick, whereas "gen" with the sum option would rather result
in cumulative sums starting from 0, thereby essentially leaving out a
few observations.
On Wed, Apr 2, 2008 at 3:57 PM, Kit Baum <[email protected]> wrote:
> Frederic said
>
> I analyse a panel data set with several observations (time) for all panel
> group, which are marked with a panel identifier. I have to select
> several panel groups out of
> the entire panel dataset on the basis of a binary variable ("binvar") coded
> 1 when fulfilling a certain criterion. Binvar==1 is mostly the case
> for only a single observation per panel group. I would like to be able
> to browse the
> entire panel for visual inspection, i.e. also the observations in that
> panel group for
> which binvar==0. The list of panel identifiers with a panel
> observation holding binvar==1 is usually fairly long so
>
> browse if binvar=="panel identifier1" | binvar=="panel identifier2" etc.
>
> is too cumbersome.
>
> Up to now I have used
>
> generate "auxiliary_var"=0
> sort "panel_identifier" "binvar"
> by "panel identifier": replace "auxiliary_var"=1 if "binvar"[_N]==1
> browse if "auxiliary_var"==1
>
> I have to do this procedure repeatedly and was wondering if there's a
> more elegant way of looking at the entire panel group, such as handing
> over the list of panel identifiers to a temporary variable such as a
> local macro, say "temp_var" and then type something along the lines of
>
> browse if "panel identifier" is a part of "temp_var"
>
>
> I think you just need
>
> bysort panel_identifier: g want = sum(binvar)
> browse if want
>
>
> Kit Baum, Boston College Economics and DIW Berlin
> http://ideas.repec.org/e/pba1.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/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/