Announcement

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

  • Reshaping an interesting panel dataset

    For some wacky reason (maybe not so wacky, it was the 1990s after all) the minimum wage paper by Card and Kruger in 1994 has data something like this
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float SHEET byte(CHAIN CO_OWNED STATE) float(WAGE_ST WAGE_ST2 NMGRS NMGRS2)
     37 1 0 0 4.25 4.25 7 7
    433 1 0 0 4.25    . 4 4
    472 1 0 0 4.25  4.9 3 3
    434 1 0 0 4.25 4.25 5 4
     51 2 0 0 4.25 4.25 3 3
    459 3 1 0 4.25 4.35 3 5
     48 1 0 0 4.25 4.38 3 5
    510 3 1 0 4.25    . 4 3
    501 1 0 0 4.25 4.75 3 6
     41 1 0 0 4.25 4.25 6 6
    444 4 0 0 4.25  4.5 3 4
    440 4 0 0 4.25    . 3 3
     60 4 0 0 4.25 4.25 5 5
    477 1 0 0 4.25 6.25 4 4
     40 1 0 0 4.25 4.25 7 6
    521 1 0 0 4.25  4.4 3 8
     59 4 0 0 4.25 4.25 3 4
    471 1 0 0 4.25 4.25 4 3
     45 1 0 0 4.25 4.25 6 2
    443 4 0 0 4.25 4.35 4 4
    430 1 0 0 4.25 4.25 4 3
    435 1 0 0 4.25 4.25 3 5
    438 2 0 0 4.25 4.25 3 3
     39 1 0 0 4.25    . 2 3
    441 4 0 0 4.25 4.25 3 3
    476 1 0 0 4.25 4.75 3 3
    522 1 0 0 4.35 4.25 4 3
    475 1 0 0  4.5  4.5 3 3
    432 1 0 0  4.5 5.05 5 4
     42 1 0 0  4.5 4.25 5 5
     50 2 0 0  4.5 4.75 3 3
    446 1 0 0  4.5    5 3 4
     47 1 0 0  4.5 4.25 . 2
    491 3 0 0  4.5    . 2 0
    514 3 0 0  4.5 4.25 3 3
    454 2 1 0  4.5    5 3 5
    497 4 1 0  4.5    . 3 5
    492 3 1 0  4.5  4.5 3 2
    485 2 1 0  4.5  4.5 3 3
    478 1 0 0  4.5 4.35 4 4
     57 4 1 0 4.67  4.5 3 4
    448 1 0 0 4.75  4.5 4 3
    466 4 0 0 4.75    . 4 3
    473 1 0 0 4.75  4.5 4 2
    407 2 1 0 4.75 4.25 3 3
    450 1 0 0 4.75 4.75 3 3
    511 3 1 0 4.75 4.75 3 3
     58 4 1 0 4.75  4.5 3 4
    498 4 1 0 4.75    5 3 3
    516 3 1 0 4.75 4.91 3 2
    503 1 0 0 4.75  4.5 4 3
    449 1 0 0 4.87    5 3 5
    458 2 1 0    5    5 2 2
    489 3 0 0    5 4.25 2 3
    493 3 1 0    5  4.9 3 4
    496 3 1 0    5 4.75 3 3
    499 4 1 0    5    5 5 5
    490 3 1 0    5    5 4 3
    474 1 0 0    5  4.5 3 3
     56 4 1 0    5 5.25 4 2
    451 1 0 0    5    5 5 6
    488 3 0 0    5 4.75 3 3
    462 3 1 0    5 4.75 3 4
    509 3 1 0    5 4.25 3 3
    445 1 0 0    5 4.75 3 5
    487 3 1 0    5 4.75 2 3
    515 3 1 0    5 4.75 4 3
    469 1 0 0    5  4.5 5 4
    483 2 1 0    5 4.75 1 3
     62 4 1 0    5    . 5 .
    468 1 0 0    5    5 3 4
    495 3 0 0    5    5 3 3
    481 2 1 0 5.25    5 3 3
    455 2 1 0 5.25    5 5 2
     61 4 1 0  5.5 4.75 5 6
    470 1 0 0  5.5 4.75 3 3
     49 2 0 0    . 4.45 4 4
     46 1 0 0    .  4.3 3 3
    506 2 1 0    .    5 2 4
    426 3 1 1 4.25 5.05 5 3
     88 1 0 1 4.25 5.05 3 4
    244 3 1 1 4.25 5.05 3 6
    106 1 0 1 4.25 5.05 3 3
    136 3 1 1 4.25    . 5 .
    202 1 0 1 4.25 5.05 4 4
    364 2 0 1 4.25 5.05 3 4
    340 1 0 1 4.25 5.05 3 2
    124 1 0 1 4.25 5.05 3 4
    262 1 0 1 4.25 5.05 3 3
    275 2 1 1 4.25 5.05 4 2
    216 2 0 1 4.25 5.05 3 3
    277 2 1 1 4.25 5.05 3 3
     96 2 0 1 4.25 5.05 2 5
    107 1 1 1 4.25 5.05 3 2
    239 2 0 1 4.25 5.05 3 2
     18 3 0 1 4.25 5.05 3 5
     80 4 0 1 4.25 5.05 . 3
    362 2 0 1 4.25 5.05 . 4
     92 1 1 1 4.25 5.05 4 3
    142 4 0 1 4.25 5.05 4 5
    end
    Here, (WAGE_ST WAGE_ST2 NMGRS NMGRS2) represent pre and post variables, respectively for wage and number of managers, and that is how they set up their DD regressions. But by modern standards, this is unacceptable! I wanna reshape the dataset such that WAGE_ST = WAGE_ST in period 1, and WAGE_ST2 = WAGE_ST2 in period 2. In normal circumstances, I would just add a time variable say time = _n, but each row does not represent a new time, the columns themselves are new time periods (each variable that ends in a 2, anyways). How might I get this to look like a normal panel dataset? I thought about making frames, but I figured there might be a way to reshape it. How might I begin this, such that SHEET (the ID) is indexed to one pre and post period, and we have one variable for wage/nmgrs .... so that it looks like a panel dataset by more modern standards?

  • #2
    I would start with

    Code:
    rename WAGE_ST WAGE_ST1
    and then see what was next.

    Comment


    • #3
      Ohhh I see, making the stubs as periods 1 and 2 and then reshaping them. Yeah this makes sense!

      Comment

      Working...
      X