Announcement

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

  • cleaning the dataset for diff and diff model

    Hi, I have the following unbalanced data. I want to clean my data to apply simple diff-in-diff model so that data may look like:

    I want to drop all the firms that do not have any year before 1997 and then let each firm id to have years only 1996 and 2005 so that I can compare those two years from difference in difference view.
    'chaebol' is my treatment variable.

    Can you help?
    Thanks

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str6 kiscode int year byte chaebol double asset
    "350257" 1980 0  18285348000
    "500607" 1980 0 131784602000
    "351253" 1980 0  62865288000
    "320498" 1980 1  33838416000
    "351156" 1980 0   6360425000
    "360252" 1980 1 541330024000
    "360317" 1980 0  22984591000
    "360228" 1980 0 132764602000
    "380911" 1980 1 213239161000
    "381152" 1980 0   6541576000
    "310140" 1980 0  49222411000
    "310166" 1980 0  14139029000
    "370274" 1980 0  21186479000
    "310026" 1980 1  24339944000
    "350648" 1980 0  28434461000
    "310123" 1980 0  34758175000
    "350117" 1980 0  17158988000
    "380806" 1980 1  15005232000
    "320129" 1980 1 217819358000
    "340251" 1980 1  25009066000
    "370118" 1980 0  58045333000
    "370177" 1980 0  36533137000
    "370150" 1980 0  41099893000
    "360287" 1980 0  57162344000
    "360090" 1980 0  83874586000
    "380784" 1980 0  44872170000
    "351350" 1980 0  45377311000
    "370053" 1980 0  28931137000
    "310190" 1980 0  30997921000
    "381160" 1980 0   6330526000
    "380938" 1980 0  50391070000
    "380733" 1980 1  16471520000
    "310590" 1980 0  44011174000
    "351067" 1980 1 130526305000
    "310476" 1980 1  47629107000
    "350451" 1980 0  16930929000
    "310174" 1980 1  76886460000
    "340324" 1980 1  29793379000
    "310433" 1980 1 110228999000
    "350320" 1980 0   4901957000
    "381250" 1980 0  13125490000
    "310131" 1980 0  32708711000
    "320099" 1980 0  46811999000
    "340154" 1980 1  26297430000
    "320218" 1980 1 159598422000
    "350591" 1980 1  36722653000
    "380989" 1980 0  14065113000
    "380954" 1980 1 299788090000
    "380474" 1980 0   4559409000
    "360155" 1980 0  16989303000
    "320293" 1980 0   5749583000
    "350729" 1980 0  11320038000
    "320536" 1980 0   7566338000
    "350940" 1980 1 3.753688e+11
    "320242" 1980 1  72924040000
    "380725" 1980 1 255463903000
    "320692" 1980 1  36229805000
    "380377" 1980 1  84495668000
    "370070" 1980 0 147094202000
    "320730" 1980 0 134657126000
    "350478" 1980 0  18782347000
    "380407" 1980 1 253086691000
    "370088" 1980 0  13385963000
    "350745" 1980 0  16256468000
    "350354" 1980 0  23786698000
    "350893" 1980 1  47589241000
    "370355" 1980 0   8763943000
    "370266" 1980 0 187501484000
    "350281" 1980 0   6170263000
    "320234" 1980 1  93930236000
    "350826" 1980 0  91398637000
    "351245" 1980 1 791687216000
    "330019" 1980 1  30833118000
    "350664" 1980 0  25927689000
    "100013" 1980 0  33738516000
    "320102" 1980 0  38081496000
    "350605" 1980 0  20336333000
    "381519" 1980 0  74751893000
    "320234" 1981 1 191479919000
    "320536" 1981 0  10653474000
    "381497" 1981 0   6876018000
    "350427" 1981 0  13974417000
    "310476" 1981 1  46282129000
    "370169" 1981 0  17031189000
    "350940" 1981 1 363957318000
    "360090" 1981 0 108913679000
    "380377" 1981 1  99681110000
    "320307" 1981 0  12349372000
    "351067" 1981 1 153999084000
    "310239" 1981 0  63909181000
    "380989" 1981 0  19277127000
    "360341" 1981 1  81424045000
    "350672" 1981 0  11976339000
    "320692" 1981 1  40404825000
    "381225" 1981 0  13215386000
    "310026" 1981 1  25694216000
    "500607" 1981 0 218146702000
    "380784" 1981 0  50509180000
    "370177" 1981 0  46809912000
    "360279" 1981 0   8186674000
    end

  • #2
    Chul-Kyoo, I think the following codes are what you want.

    Code:
    keep if year == 1996 | year == 2005
    bysort kiscode: keep if _N == 2

    Comment


    • #3
      Thank you so much!

      Comment

      Working...
      X