Hi,
I am trying to do a 1 to 1 match. I did it the following way. The results were 2721 matches which I am confused about since my control observations are over 400,000 and trying to get one match for each of my 7,000 observations in my sample. Can anyone help me figure it out. Ultimately there should be 7,000 matches so there is a total of 14,000 individual observations.
my data has gvkey (company identifier), fyear (fiscal year), sic (industry), TA (total assets)
proc sql;
create table want as
select s.*, c.gvkey as match_firm, c.AT as match_assets, c.fyear as match_year
from sample1 as s inner join control1 as c
on s.sic=c.sic
where c.gvkey ne s.gvkey
group by s.gvkey
having abs(s.AT-c.AT) = min(abs(s.AT-c.AT));
select * from want;
quit;
Why do you expect 14000 obs and not 7000?
I expect 7000 matches so 14,000 total observations ---- 7000 from my sample and 7000 from the control. Regardless, it doesnt make sense to have less than half.
Possible causes that I can think of
Many sic have a single gvkey in the control dataset
Many AT values are missing in the sample dataset
Some sic in the sample do not occur in the control dataset
if none of those apply, I'm as puzzled as you are.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.