Announcement

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

  • How to combine 2 rows of data into 1 row_

    Dear stata user,

    I'm trying to combine 2 or more rows of information into 1 row, because they are about the same firm's information, but different deals this firm involve
    Some of my dataset is like this:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte nbidder long apermno double dealnumber int(adate edate) long tpermno
    2 22983 441066020 12771 12823 66069
    2 36542 441283020 12598 13048 66069
    end
    format %tdnn/dd/CCYY adate
    format %tdnn/dd/CCYY edate
    I want to put different deals of the same firm(identified by tpermno) in the same row (including the corresponding adate, edate, apermno related to this deal, and also nbidder), I think reshape might do but I couldn't figure it out.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    tpermno dealnumber1 adate1 edate1 apermno1 dealnumber2 adate2 edate2 apermno2 nbidder
    66069 441066020 12771 12823 22983
    66069 441283020 12598 13048 36542
    end
    format %tdnn/dd/CCYY adate
    format %tdnn/dd/CCYY edate
    Can someone indicate me what I should do?
    Thanks a lot!

  • #2
    Hi thanks all, but I think I solve it using reshape, I first generate an id for each deal of the same tpermno and then use this as j(), use tpermno as i() to reshape wide.
    But another question, now that I have dealnumber1 and dealnumber2, and my dataset is wide, is there a way to see the number of unique dealnumber (considering all dealnumberx) in my dataset?

    Comment


    • #3
      Lucrecia:
      the main issue here is what you're going to do with your data.
      For instance, if you're planning a panel data regression, the -long- format is the way to go (and this holds for many other Stata commands).
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment

      Working...
      X