Announcement

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

  • Panel Data: How many instances shared an organization code in the past period

    Hi all,

    I'm running into some trouble with a dataset of bank mergers.

    I have data at the branch/location level, and the attributes I have are:

    BranchID (unique for every location)
    BankID (will be shared by locations owned by the same corporate entity)
    Revenue (annual)
    Year

    The trouble is, the BankID appears to change every year, even if it's verifiably the same corporation there as before. Is there a way to generate a dummy variable to see if at least 1/2 of current establishments that currently share a BankID with a given branch also shared a BankID with that branch in the last period?

    The dataset looks like this:
    BranchID BankID Revenue (million) Year
    1 115 $70 1990
    2 115 $65 1990
    3 120 $120 1990
    4 120 $55 1990
    1 134 $78 1991
    2 134 $70 1991
    3 180 $111 1991
    4 180 $62 1991
    1 155 $80 1992
    2 155 $66 1992
    3 155 $132 1992
    4 190 $71 1992
    And I'd want it to look like this --
    BranchID BankID Revenue (million) Year LargerPartner
    1 115 $70 1990 1
    2 115 $65 1990 1
    3 120 $120 1990 1
    4 120 $55 1990 1
    1 134 $78 1991 1
    2 134 $70 1991 1
    3 180 $111 1991 1
    4 180 $62 1991 1
    1 155 $80 1992 1
    2 155 $66 1992 1
    3 155 $132 1992 0
    4 190 $71 1992 0

    Thanks so much for your time!

  • #2
    Cyril:
    welcome to this forum.
    You may want to consider the -group- function available from -egen-:
    Code:
    . sort branchID (Year)
    
    . egen wanted=group( BankID)
    
    . list
    
         +---------------------------------------------+
         | branchID   BankID   Revenue   Year   wanted |
         |---------------------------------------------|
      1. |        1      115        70   1990        1 |
      2. |        2      115        65   1990        1 |
      3. |        3      120       120   1990        2 |
      4. |        4      120        55   1990        2 |
         +---------------------------------------------+
    
    .
    Otherwise you can go:
    Code:
    . bysort BankID (Year): gen wanted2=1 if _n==1
    
    
    . replace wanted2=1 if wanted[_n]== wanted[_n-1]
    
    
    .
    Last edited by Carlo Lazzaro; 24 Apr 2024, 01:00.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X