Announcement

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

  • How to subset first row of each group?

    I have a dataframe of about 3 000 acquisition bids.

    Variables:
    • Company ID (PERMNO)
    • Bid ID (ID)
    • Announcement date (ANDATE)
    • Bidding round (ROUND_ID)
    Click image for larger version

Name:	Screen Shot 2021-08-12 at 13.44.47.png
Views:	1
Size:	73.0 KB
ID:	1623034

    Bids are in competition with each other and grouped by ROUND_ID.

    Problem:
    I would like to write a code that runs through each ROUND_ID and saves the first observation (by ANDATE) in a separate dataframe. I.e. I would like to subset the first bid of each bidding round, and then create a different subset with the follower-bids.

    Can anyone help me with this?

  • #2
    I am on old Stata 15 which does not have frames, but what you seem to want is

    Code:
    bysort ROUND_ID (ANDATE): keep if _n==1
    If you still cannot figure it out, provide a usable sample of your data using -dataex-.

    Comment

    Working...
    X