BookmarkSubscribeRSS Feed
dowen
Calcite | Level 5

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 

1 REPLY 1
PGStats
Opal | Level 21

The significant difference is not surprising, since you are minimysing the square of differences. If the treatment group is significantly greater or lower than the control group, you will find the same trend in matched pairs.

PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 896 views
  • 1 like
  • 2 in conversation