Hello! I am new to programming and need some help with basic subsetting in STATA or R. Hoping someone is willing to help as an easy challenge!

Dataset:

127 000 successful & unsuccesful acquisition bids in the US, 01/01/80 - 31/12/20

Relevant variables include:
  • Bid announcement date
  • Bid completion date (if successful)
  • Target ID
  • Acquirer ID
  • % acquired
  • % sought
  • Competing bid flag (YES/NO)
  • Divestiture flag (YES/NO)
I want to subset the dataset into two samples:
  1. Single bidder sample (no competing bids)
  2. Competition sample (two or more bidders)
The competition sample is defined by two possible scenarios:
1. Exactly two bids
  • 2 bids announced for the same target + 1 bid completed with at least 50% acquired = competition
  • 2 bids completed + 1 bid acquires at least 50% +
    • Competing bid flag = YES, or
    • Announcement dates <= 12 months apart + bid 1 is not completed before bid 2 is announced + divestiture = NO
      = competition
2. Multiple bids
  • 2+ bids announced for the same target + 1 bid completed with at least 50% acquired = competition
  • 2+ bids completed + 1 bid acquires at least 50% +
    • Competing bid flag = YES, or
    • No bid is completed before other bids are announced + divestiture flag = NO
      = competition


Thanks a lot!