Announcement

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

  • Find matched firms

    Hello everyone,

    Hope everything is going well.

    I have a question about how to identify the matched firm. The sample data is the following.

    I want to identify the target firms (target=1) that match with focal firms (target=0) by the following criteria:


    1. target firms (target=1) and focal firms(target=0) are in the same industries (same industry code);

    2. the Size different between target firms (target=1) and focal firms(target=0) is less than 5% ( |% diff in Size| < 5% of focal firms (target=0)).


    For example, for firms in 2009, target firm (target = 1, symbol = 466) is matched with focal firm (target = 0, symbol = 1889). Because these two firms share same industry code (industry = "C"). Also, target firm size (target = 1, symbol = 466, Size = 10.98468) is within 5% of focal firm size (target = 0, symbol = 1889, Size = 10.68249). In the other word, |10.98468 - 10.68249| < 5%*10.68249.

    Much appreciated for your help, in advanced. And have a lovely day.

    Cheers,
    Frank


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double symbol float(year lag_Size target) str1 industry
       353 2009 11.908743 1 "C"
       430 2009  14.15009 1 "C"
       466 2009 10.984676 1 "C"
       469 2009  9.873674 1 "C"
       526 2009 13.150103 1 "C"
       631 2009  12.35215 1 "C"
       709 2009 12.046097 1 "C"
      1889 2009 10.682493 0 "C"
      1981 2009 11.658934 1 "I"
    599931 2009  11.79596 1 "D"
    600182 2009  11.63502 0 "F"
    600289 2009 13.280113 0 "B"
    600695 2009 13.557528 1 "S"
       288 2010  14.53094 1 "C"
       365 2010 11.574177 1 "C"
       381 2010 12.807743 0 "C"
       602 2010  10.66294 0 "L"
       652 2010 11.655706 0 "C"
      1817 2010  11.09666 1 "C"
      1998 2010  9.882786 0 "C"
      2017 2010 11.316225 0 "C"
      2063 2010 11.951778 0 "C"
      2185 2010 14.827463 1 "C"
    299851 2010  11.65016 0 "I"
    299886 2010 11.679768 0 "C"
    599925 2010 12.312794 . "G"
    599928 2010 12.259146 1 "F"
    600302 2010  12.15644 1 "E"
    600488 2010 14.607515 1 "C"
    600771 2010 13.569136 1 "B"
    601527 2010 15.686802 1 "C"
       201 2011  14.60073 0 "C"
       313 2011 12.489162 1 "C"
       431 2011 13.445896 0 "K"
       606 2011 12.256338 0 "C"
       635 2011 10.814608 0 "C"
      1916 2011  11.85497 1 "M"
      1919 2011 11.543577 1 "C"
      1951 2011 11.106693 0 "C"
      2117 2011 11.584675 1 "C"
      2235 2011 11.244164 0 "C"
      2301 2011 11.771706 0 "C"
    299827 2011 11.895157 0 "R"
    299843 2011  10.90149 0 "C"
    299916 2011 10.531273 0 "C"
    299927 2011 11.159685 1 "C"
    299943 2011 11.030184 0 "A"
    299945 2011 11.296352 0 "C"
    300000 2011  12.55377 1 "C"
    599855 2011  11.19978 0 "C"
    600537 2011 13.267574 1 "C"
    600601 2011  14.07104 1 "C"
    600767 2011 12.057472 1 "C"
       344 2012  11.50715 1 "D"
       535 2012  12.47966 0 "A"
       556 2012 12.291164 1 "C"
      1905 2012   11.5334 1 "C"
      2109 2012  13.20733 0 "C"
      2121 2012 12.041492 0 "A"
      2299 2012 11.014174 0 "C"
      2330 2012 10.996252 0 "C"
      2412 2012 12.061598 1 "C"
    300120 2012  12.92989 1 "C"
    300120 2012  12.92989 1 "C"
    599920 2012 13.254177 1 "F"
    599992 2012 12.251202 1 "C"
    600056 2012 14.127745 0 "S"
    600333 2012  13.56007 1 "K"
    600350 2012 14.038223 1 "C"
    600475 2012 14.364258 1 "K"
    600479 2012 11.347134 1 "C"
    600664 2012  12.63239 1 "D"
    600807 2012 12.063375 1 "H"
    601315 2012 14.573185 1 "C"
    601416 2012 12.484383 0 "C"
    601677 2012  13.31427 1 "C"
       321 2013 13.256262 0 "C"
       483 2013  13.49034 1 "C"
       766 2013 13.705702 1 "D"
      1848 2013  12.84603 0 "C"
      1872 2013 11.593857 0 "C"
      1950 2013 11.065273 1 "C"
      1970 2013 11.810514 0 "C"
      2082 2013 11.373936 0 "C"
      2383 2013 12.126085 0 "C"
      2411 2013  11.05875 0 "C"
    299935 2013  11.59205 1 "C"
    299981 2013  11.04519 0 "C"
    599943 2013 13.732157 0 "C"
    600091 2013 13.992184 0 "C"
    600298 2013  13.71964 1 "C"
    600310 2013 13.627623 0 "K"
    600317 2013 11.963255 1 "C"
    600485 2013 13.576433 1 "C"
    600502 2013 12.433384 0 "C"
    600519 2013  11.57269 1 "D"
    600546 2013  10.85954 1 "C"
    600680 2013  12.33401 1 "R"
    600682 2013  11.80856 0 "B"
    600770 2013 14.250835 0 "C"
    end
    ------------------ copy up to and including the previous line ------------------

  • #2
    Code:
    tempfile target
    preserve
    keep if target==1
    ren symbol symbol_target
    ren lag_Size lag_Size_target
    save `target'
    restore
    keep if target==0
    joinby year industry using `target'
    gen match=abs(1-lag_Size_target/lag_Size)<=0.05
    keep if match==1

    Comment

    Working...
    X