Announcement

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

  • Coding a mass-layoff event with successor firms

    Hello all! I've been trying to determine the best way to generate a flag when a mass layoff happens at the firm level. In the example below, I have firm level data for the years 1990-1996, with employment totals at each firm. I also have information on if a firm changes its identifier to a new one (or multiple new ones) captured as firm_succ*. I'd like some advice on the best way to check how many employees transition to the new successor firms to verify if there was an event. To do this, I need the total employment at the new firms. What is the best way to calculate total employment transitioned to the new firm identifiers? I'd like to generate something like emp_firm_succ that shows the employment in the following year at the new firm_succ*.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str1 firmid float(year emp) str1(firm_succ1 firm_succ2)
    "1" 1990  50 "." "."
    "1" 1991  49 "." "."
    "1" 1992  52 "." "."
    "1" 1993  51 "2" "."
    "1" 1994   . "." "."
    "1" 1995   . "." "."
    "1" 1996   . "." "."
    "2" 1994  30 "." "."
    "2" 1995  31 "." "."
    "2" 1996  30 "." "."
    "3" 1990 100 "." "."
    "3" 1991 105 "." "."
    "3" 1992 104 "4" "5"
    "3" 1993   . "." "."
    "3" 1994   . "." "."
    "3" 1995   . "." "."
    "3" 1996   . "." "."
    "4" 1993  51 "." "."
    "4" 1994  50 "." "."
    "4" 1995  51 "." "."
    "4" 1996  51 "." "."
    "5" 1993  52 "." "."
    "5" 1994  52 "." "."
    "5" 1995  52 "." "."
    "5" 1996  52 "." "."
    end
    Thanks!
    Last edited by Jennifer Bernard; 14 Jun 2019, 15:34.

  • #2
    To clarify: I'd like to generate a new variable that gives total emp in the year following at the successor firms. For instance, Firm 3 in 1992 splits into two successors, who have IDs 4 and 5. In the following year, these two firms have a combined employment of 103 (51+52). I want this to be my new variable, tot_emp_to_successor, for the original Firm 3.

    Any help at all would be greatly appreciated. I've tried using a matching technique between firmid and firm_succ* which will give me a flag if there is a successor, but can't quite figure out how to build the new employment variable.

    Comment


    • #3
      You can try something as below.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str1 firmid float(year emp) str1(firm_succ1 firm_succ2)
      "1" 1990  50 "." "."
      "1" 1991  49 "." "."
      "1" 1992  52 "." "."
      "1" 1993  51 "2" "."
      "1" 1994   . "." "."
      "1" 1995   . "." "."
      "1" 1996   . "." "."
      "2" 1994  30 "." "."
      "2" 1995  31 "." "."
      "2" 1996  30 "." "."
      "3" 1990 100 "." "."
      "3" 1991 105 "." "."
      "3" 1992 104 "4" "5"
      "3" 1993   . "." "."
      "3" 1994   . "." "."
      "3" 1995   . "." "."
      "3" 1996   . "." "."
      "4" 1993  51 "." "."
      "4" 1994  50 "." "."
      "4" 1995  51 "." "."
      "4" 1996  51 "." "."
      "5" 1993  52 "." "."
      "5" 1994  52 "." "."
      "5" 1995  52 "." "."
      "5" 1996  52 "." "."
      end
      
      tempfile data
      save `data'
      
      forval i=1/2{
      drop firm_succ1 firm_succ2
      rename (firmid emp) (firm_succ`i' emp`i')
      replace year= year-1
      tempfile ds`i'
      save `ds`i''
      use `data', clear
      }
      
      forval i=1/2{
      merge m:1 firm_succ`i' year using `ds`i''
      drop if _merge==2
      drop _merge
      }
      Adjust the total number of firms as desired. At the moment, these equal 2, so I have "forval i=1/2" in the loop. Thereafter, just sum the "emp" variables.

      Result:

      Code:
      . sort firmid year
      
      . l, sepby(firmid)
      
           +---------------------------------------------------------+
           | firmid   year   emp   firm_s~1   firm_s~2   emp1   emp2 |
           |---------------------------------------------------------|
        1. |      1   1990    50          .          .      .      . |
        2. |      1   1991    49          .          .      .      . |
        3. |      1   1992    52          .          .      .      . |
        4. |      1   1993    51          2          .     30      . |
        5. |      1   1994     .          .          .      .      . |
        6. |      1   1995     .          .          .      .      . |
        7. |      1   1996     .          .          .      .      . |
           |---------------------------------------------------------|
        8. |      2   1994    30          .          .      .      . |
        9. |      2   1995    31          .          .      .      . |
       10. |      2   1996    30          .          .      .      . |
           |---------------------------------------------------------|
       11. |      3   1990   100          .          .      .      . |
       12. |      3   1991   105          .          .      .      . |
       13. |      3   1992   104          4          5     51     52 |
       14. |      3   1993     .          .          .      .      . |
       15. |      3   1994     .          .          .      .      . |
       16. |      3   1995     .          .          .      .      . |
       17. |      3   1996     .          .          .      .      . |
           |---------------------------------------------------------|
       18. |      4   1993    51          .          .      .      . |
       19. |      4   1994    50          .          .      .      . |
       20. |      4   1995    51          .          .      .      . |
       21. |      4   1996    51          .          .      .      . |
           |---------------------------------------------------------|
       22. |      5   1993    52          .          .      .      . |
       23. |      5   1994    52          .          .      .      . |
       24. |      5   1995    52          .          .      .      . |
       25. |      5   1996    52          .          .      .      . |
           +---------------------------------------------------------+
      Last edited by Andrew Musau; 18 Jun 2019, 07:37.

      Comment


      • #4
        Thanks for this! I had seen something similar, but was wondering if I could accomplish without having to chop and merge. I have millions of observations and sometimes there are many (up to ~100!) successor firms. Looks like this may be my only choice.

        Comment

        Working...
        X