Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Drop panel if condition of at least one observation of panel is true

    Hi together,

    i use stata 16.0 and have a panel data set including banks (unique identifier is the variabel "SNLInsititutionKey"), "quarters" from 200q1-2019q4 and "assets" (in thousand, $000):

    My question is now, how i can delete all oberservations of a bank (e.g. SNLInstitutionKey) if at least one of its quarterly observations have assets that are lower than $100 million.

    I tried: by SNLInsitutionKey: drop if assets<=100000
    But it only deletes the obeservations where assets is equal/smaller than $100 million and not all obervations of the bank which may only show in one quarter lower than $100 million assets.

    Snapshot from my dataset:
    Click image for larger version

Name:	drop panel if one condition of at least one observation of panel is true.PNG
Views:	1
Size:	51.0 KB
ID:	1551554


    Thanks a lot for your help,
    Lea

  • #2
    Code:
    bys SNLInsititutionKey: egen todrop= max(assets<=100000)
    drop if todrop

    Comment


    • #3
      Code:
      bysort SNLInstitutionKey: egen tag = max(assets <= 100000)
      drop if tag
      or
      Code:
      bysort SNLInstitutionKey (assets): drop if assets[1] <= 100000

      Comment


      • #4
        it works perfectly. Thanks a lot Andrew and Wouter.

        Comment

        Working...
        X