I have 2 datasets: treatment firms and control firms. I need to match these two datasets based on this equation:
match error=∑_(k=1)^3〖((c_k^i-c_k^j)/(c_k^i+c_k^j ))〗^2
where i=treatment firm, j= control firm, and c_k is one of the three variables: log market capitalization, log volume, and price. I would like to match each test firm with a control firm (without replacement) based on the smallest match error from of the above equation.
Here is my sas code:
data control;
set control;
rename price_Mean=_price_Mean log_volume=_log_volume log_mrk_cap =_log_mrk_cap;
k+1;
run;
data want;
if _n_ eq 1 then do;
if 0 then set control;
declare hash h(dataset:'control',multidata:'y');
h.definekey('control pool');
h.definedata('_price_Mean','_log_volume','_log_mrk_cap','k');
h.definedone();
end;
call missing(of _all_);
set treatment;
n=0;
min=9999999;
rc=h.find();
do while(rc=0);
merror=(((price_Mean-_price_Mean)/(price_Mean+_price_Mean))**2)+(((log_adv-_log_volume)/(log_volume+_log_volume))**2)+(((log_mrk_cap-_log_mrk_cap)/(log_mrk_cap+_log_mrk_cap))**2);
if merror lt min then do;n=k;min=merror;end;
rc=h.find_next();
end;
rc=h.find();
do while(rc=0);
if n=k then do;h.removedup();leave;end;
rc=h.find_next();
end;
run;
My problem that I'm having is that once I test the difference between the two groups by each criteria variable, they are significantly different. However, I know this could just be natural by the experiment I'm running but I want to make sure that it is not the result of the code.
Any comments or help would be appreciated. Thank you,
Best, Donovan