Announcement

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

  • Deleting observations with condition

    Hi everyone,
    I am trying to delete banks with total assets growth that is above 25% (yearly changes are above 25%). So if a bank has more than 25% assets growth in a year, I would like to delete all the observations for the years following this 25% assets growth. Example: Bank A has observations from 2000 to 2015; assets growth ratio was 28% in 2011 and I would like to delete the observations following the asset growth, i.e. 2011 to 2015. Can you please advise on how I can do this for a panel of banks ? Thank you.

  • #2
    Is assets growth already a variable in the dataset? If not, make that so.

    Then dropping from the first year with assets growth over 25% is some variation on

    Code:
    gen was_high = inrange(assets_growth, 25, .)
    
    bysort bank_id : egen first_high = min(cond(was_high, year, .))
    
    drop if year >= first_high
    See also FAQ https://www.stata.com/support/faqs/d...t-occurrences/

    I had to invent variable names because you don't mention any of yours.
    Last edited by Nick Cox; 10 Jan 2022, 10:20.

    Comment


    • #3
      It worked! Thank you, Nick. I appreciate it!

      Comment

      Working...
      X