Related techniques are discussed at
FAQ . . Creating variables recording whether any or all possess some
char.
2/03 How do I create a variable recording whether any
members of a group (or all members of a group)
possess some characteristic?
http://www.stata.com/support/faqs/data/anyall.html
Nick
[email protected]
postkarte
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
*
* 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/