BookmarkSubscribeRSS Feed
dlazer1
Calcite | Level 5

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;

3 REPLIES 3
PGStats
Opal | Level 21

Why do you expect 14000 obs and not 7000?

PG
dlazer1
Calcite | Level 5

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. 

PGStats
Opal | Level 21

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.

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
  • 3 replies
  • 1804 views
  • 0 likes
  • 2 in conversation