Dear all,

I am analyzing whether a CEO turnover (c. 600 events) has a long-term impact on operating performance (OROA). The performance measure needs to be control-group adjusted according to Barber & Lyon's (1995) method on performance matching, replicating a study by Huson et al (2004):
"The Barber and Lyon matching method is performed as follows. Each sample firm is matched to comparison firms with the same two-digit Compustat SIC code whose performance measures over the year before the turnover are within 10% of the sample firm’s performance. If there are no such firms, we match performance within the 10% filter using all firms with the same one-digit SIC code. For firms without matches after this procedure, we use all firms with performance within the filter bounds regardless of SIC code. Each sample firm’s performance is adjusted by subtracting the median performance of its control group. Changes over time in adjusted performance are then calculated. This procedure is intended to isolate the component of performance change due to management turnover from that attributable to mean reversion of industry and firm-specific factors."
I have started working with the following code (provided in another post by Clyde Schechter):

Code:
//    CREATE A FILE OF JUST CONTROLS
//    AND RENAME THE VARIABLES
preserve
keep if Turnover == 0
ds digitSNICode, not
rename (`r(varlist)') =_ctrl
tempfile controls
save `controls'

//    BRING BACK THE DATA & KEEP ONLY CASES
restore
keep if Turnover == 1

//    UNIQUELY IDENTIFY EACH OBSERVATION
gen long obs_no = _n
    
//    MATCH EXACTLY ON industry
joinby digitSNICode using `controls'
drop if missing(CompanyID_ctrl)    // NO MATCHES AVAILABLE

//    RETAIN THE BEST MATCH ON Oroa
gen delta = abs(ROABencht1-ROABencht1_ctrl)
set seed 1234 // OR YOUR FAVORITE SEED NUMBER
gen double shuffle1 = runiform()
gen double shuffle2 = runiform()
by obs_no (delta shuffle1 shuffle2), sort: keep if _n == 1

//    DO MATCHED-PAIRS CONTRAST OF ΔOROA
ttest ΔOROAt1 = ΔOROAt1_ctrl
ttest ΔOROAt2 = ΔOROAt2_ctrl
ttest ΔOROAt3 = ΔOROAt3_ctrl
ttest ΔOROAt4 = ΔOROAt4_ctrl
ttest ΔOROAt5 = ΔOROAt5_ctrl
signrank ΔOROAt1 = ΔOROAt1_ctrl
Example of data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long CompanyID int DataYearFiscal byte digitSNICode double OROA byte(Turnover Forcedvoluntary Externalinternal) double(OROABencht1 ΔOROAt1 ΔOROAt2 ΔOROAt3 ΔOROAt4 ΔOROAt5) long obs_no
 4439 2003 36 -.04915325039492575 1 1 1 -.07741066001215728      .22272353698888614    .24526468099117826    .2070861361194029     .1842730402112826   .16822035497415502  1
 4439 2010 36  .08991175238780026 1 0 0  .08267176320689994     .005212132256435936  -.019725221574862728 .0028022073235805106 -.0035566400596804965   .01218513049042734  2
 4439 2017 36 -.04200150345689208 1 1 0  .05170152234995411                       .                     .                    .                     .                    .  3
11217 2011 37  .08588490190467506 1 0 0  .05487186432516215    -.002163254978648124  -.028028425956137932  -.02155970090503217 -.0025182226052173073                    .  4
11217 2015 37  .05235364171994484 1 1 1  .03331216342012998      .02344087334172642    .03810638083480089                    .                     .                    .  5
11749 2003 35  .08413924018161763 1 0 0  .09756216837420838     .027389656764810505    .05585132489637447   .05579974889759513    .05984083348573367   .06479133144232914  6
11749 2015 35  .08504513774054068 1 1 0  .10549224549590794     -.01435056012096908 -.0055005880656577855                    .                     .                    .  7
12368 2002 24  .08318350376446791 1 0 0  .11296369024242207     -.04306698316209534   -.06389330759031134  -.05434671259222728   -.05386740271099181  -.04718012827033796  8
12368 2007 24  .06578356197208411 1 1 0 .059096287531430265  -.00029587388096490724  .0013750022879044435  .004276616331534248 -.0055565821222064715  .001959509424053027  9
12368 2015 24  .07974227070623513 1 1 0  .07816717273954116     .008121646728602591                     .                    .                     .                    . 10
14620 2002 36  .08546592268679788 1 0 0  .07212821775939694      .01314055916512076   .013658768790948392  .018273746688369036   -.01848108483466524 -.002028746154982039 11
14620 2011 36 .041675167639177925 1 0 0   .0894547155276769     -.02238569583768947  -.037939325255589504  -.02790289384112015  -.033005737841186385 -.017465641478006957 12
14620 2016 36  .07198907404966995 1 0 0  .05644897768649052      .02599907002574505                     .                    .                     .                    . 13
15654 2001 60 .034678194703205656 1 0 0  .05284249332736598     -.02910856264413426  -.031498695920840494 -.028081573849146228  -.026712287040164977 -.032482318648909846 14
15654 2006 60 .020360174678456133 1 0 0 .026130206287201002     .009818236401323295    .01661679244678696 -.006198615169238298  -.008783657343166988 -.000829885418673515 15
15654 2015 60  .01271143716920228 1 0 0 .017220618795199306   -.0040012524889815135                     .                    .                     .                    . 16
15654 2016 60 .013219366306217792 1 1 0  .01271143716920228 -.000015344186305469784                     .                    .                     .                    . 17
15671 2005 60 .016680512631667588 1 0 0 .016528150458850407      .00232949012412988   .028479166900531448  .022758048251130814  .0030165824485197217  .001859122543328321 18
15671 2017 60  .01518404240786432 1 0 0 .015047092025365751                       .                     .                    .                     .                    . 19
15699 2005 67    .526054101666628 1 0 0  .12466413971787736        .060169078650274    -.1203588451450908   -.3256334960945835    .10925619243292707   .06134370876412283 20
end
----------

The problems I currently have are the following:
1. The matching needs to take into account that I don't have an equal number of observations in ΔOROAt. I.e., currently an observation with the entire 5-year window (ΔOROAt1 ΔOROAt2 ΔOROAt3 ΔOROAt4 ΔOROAt5) can be matched to an observation containing only e.g. ΔOROAt1. How can I adjust for that in the code? Ideally, that would be the first criteria in the matching procedure.
2. I'm not really sure how the "retain the best match" procedure actually works right now. Can that be adjusted to strictly follow the "within 10%"-rule?
3. How can I make sure this is followed: "For firms without matches after this procedure, we use all firms with performance within the filter bounds regardless of SIC code."?

Many thanks,
Carl-Johan