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

RE: st: re: browsing a subset of panels in a panel dataset

From   "Nick Cox" <>
To   <>
Subject   RE: st: re: browsing a subset of panels in a panel dataset
Date   Thu, 3 Apr 2008 19:24:25 +0100

Related techniques are discussed at 

FAQ     . . Creating variables recording whether any or all possess some
        2/03    How do I create a variable recording whether any
                members of a group (or all members of a group)
                possess some characteristic?



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 <> wrote:
> Frederic said
> I analyse a panel data set with several observations (time) for all
> 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")
> 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"
> 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:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index