If you want 1:1, then add k2k and then restrict sample to cem_matched.
-
Login or Register
- Log in with
* Example generated by -dataex-. For more info, type help dataex clear input str6 GlobalCompanyKey int(DataDate DataYearFiscal StockExchangeCode) double AssetsTotal byte NAICS "001004" 22066 2019 90 2079 42 "001004" 22431 2020 90 1539.7 42 "001004" 22796 2021 90 1573.9 42 "001004" 23161 2022 90 1833.1 42 "001004" 23527 2023 90 2770 42 "001075" 22280 2020 11 20020.421 22 "001075" 22645 2021 11 22003.222 22 "001075" 23010 2022 11 22723.405 22 "001075" 23375 2023 11 24661.153 22 "001078" 22280 2020 11 72548 33 "001078" 22645 2021 11 75196 33 "001078" 23010 2022 11 74438 33 "001078" 23375 2023 11 73214 33 "001186" 22280 2020 11 9614.755 21 "001186" 22645 2021 11 10186.776 21 "001186" 23010 2022 11 23494.808 21 "001186" 23375 2023 11 28684.949 21 "001209" 22188 2020 11 25168.5 32 "001209" 22553 2021 11 26859.2 32 "001209" 22918 2022 11 27192.6 32 "001209" 23283 2023 11 32002.5 32 "001230" 22280 2020 11 14046 48 "001230" 22645 2021 11 13951 48 "001230" 23010 2022 11 14186 48 "001230" 23375 2023 11 14613 48 "001254" 22280 2020 11 2900.6 48 "001254" 22645 2021 11 3693.1 48 "001254" 23010 2022 11 4330 48 "001254" 23375 2023 11 4294.6 48 "001257" 22280 2020 11 1404.138 53 "001257" 22645 2021 11 1391.965 53 "001257" 23010 2022 11 1397.776 53 "001257" 23375 2023 11 1403.68 53 "001380" 22280 2020 11 18821 21 "001380" 22645 2021 11 20515 21 "001380" 23010 2022 11 21695 21 "001380" 23375 2023 11 24007 21 "001393" 22005 2019 11 13438.024 53 "001393" 22370 2020 11 14651.606 53 "001393" 22735 2021 11 17299.581 53 "001393" 23100 2022 11 18124.648 53 "001393" 23466 2023 11 19058.758 53 "001410" 22219 2020 11 3776.9 56 "001410" 22584 2021 11 4436.2 56 "001410" 22949 2022 11 4868.9 56 "001410" 23314 2023 11 4933.7 56 "001545" 22280 2020 11 865.764 53 "001545" 22645 2021 11 770.569 53 "001545" 23010 2022 11 1197.479 53 "001545" 23375 2023 11 1023.484 53 "001585" 22280 2020 11 680.293 32 "001585" 22645 2021 11 694.16 32 "001585" 23010 2022 11 726.313 32 "001585" 23375 2023 11 767.548 32 "001598" 22280 2020 11 10357.483 33 "001598" 22645 2021 11 11898.187 33 "001598" 23010 2022 11 12431.12 33 "001598" 23375 2023 11 15023.533 33 "001613" 22280 2020 11 463.208 33 "001613" 22645 2021 11 485.632 33 "001613" 23010 2022 11 502.774 33 "001613" 23375 2023 11 565.654 33 "001618" 22400 2020 90 97.366 23 "001618" 22765 2021 90 94.917 23 "001618" 23130 2022 90 115.895 23 "001618" 23496 2023 90 122.83 23 "001661" 22280 2020 11 5503.428 21 "001661" 22645 2021 11 5525.364 21 "001661" 23010 2022 11 4729.854 21 "001661" 23375 2023 11 5277.965 21 "001706" 22158 2020 11 824.294 33 "001706" 22523 2021 11 820.247 33 "001706" 22888 2022 11 757.312 33 "001706" 23253 2023 11 762.597 33 "001712" 22280 2020 11 316.833 32 "001712" 22645 2021 11 293.54 32 "001722" 22280 2020 90 49719 31 "001722" 22645 2021 90 56136 31 "001722" 23010 2022 90 59774 31 "001722" 23375 2023 90 54631 31 "001773" 22280 2020 90 17053.911 42 "001773" 22645 2021 90 19535.54 42 "001773" 23010 2022 90 21763.182 42 "001773" 23375 2023 90 21726.168 42 "001794" 22188 2020 11 6877 32 "001794" 22553 2021 11 6612 32 "001794" 22918 2022 11 6213 32 "001794" 23283 2023 11 5939 32 "001864" 21945 2019 11 500.502 32 "001864" 22311 2020 11 479.345 32 "001864" 22676 2021 11 550.361 32 "001864" 23041 2022 11 579.579 32 "001864" 23406 2023 11 664.802 32 "001913" 22280 2020 11 6083.9 32 "001913" 22645 2021 11 7971.6 32 "001913" 23010 2022 11 7950.5 32 "001913" 23375 2023 11 8209.8 32 "001926" 21974 2019 11 1073.831 33 "001926" 22339 2020 11 996.442 33 "001926" 22704 2021 11 1133.028 33 end format %tdnn/dd/CCYY DataDate
gen delta = assets_120/assets_11 keep if inrange(delta, 0.75, 1.25) replace delta = abs(log(delta))
gen delta1 = assets_99/assets_120 gen delta2 = assets_99/assets_11 keep if inrange(delta1, 0.75, 1.25) & inrange(delta2, 0.75, 1.25) replace delta1 = abs(log(delta1)) replace delta2 = abs(log(delta2)) gen delta = max(delta1, delta2)
// SEPARATE INTO THREE DATA SETS preserve keep if StockExchangeCode == 11 rename (GlobalCompanyKey AssetsTotal) =_11 // SUFFIX IN RENAME MUST MATCH STOCK EXCHANGE drop StockExchangeCode tempfile SE11 // DECLARATION IN TEMPFILE MUST MATCH SUBSEQUENT USE OF THE FILE save `SE11' // N.B. NO .dta restore, preserve keep if StockExchangeCode == 120 rename (GlobalCompanyKey AssetsTotal) =_120 drop StockExchangeCode tempfile SE120 save `SE120' restore keep if StockExchangeCode == 90 rename (GlobalCompanyKey AssetsTotal) =_90 drop StockExchangeCode tempfile SE90 save `SE90'
joinby industry_code year using `SE90.dta' drop shuffle gen double shuffle = runiform() gen delta1 = assets_99/assets_120 gen delta2 = assets_99/assets_11 keep if inrange(delta1, 0.75, 1.25) & inrange(delta2, 0.75, 1.25) replace delta1 = abs(log(delta1)) replace delta2 = abs(log(delta2)) gen delta = max(delta1, delta2) // MATCHING WITHOUT REPLACEMENT local allocation_ratio 1 local current 1 sort id_120 year (delta shuffle) while `current' < _N { local end_current = `current' + `allocation_ratio' - 1 while id_120[`end_current'] != id_120[`current'] /// & year[`end_current'] != year[`current'] { local end_current = `end_current' - 1 } // KEEP REQUIRED # OF MATCHES FOR THE CURRENT CASE drop if id_120 == id_120[`current'] & year == year[`current'] in `=`end_current'+1'/L // REMOVE THE SELECTED MATCHES FROM FURTHER CONSIDERATION forvalues i = 0/`=`allocation_ratio'-1' { drop if id_90 == id_90[`current'+`i'] & year == year[`current' + `i'] & _n > `end_current' } local current = `end_current' + 1 }
Comment