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

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1040 views
  • 0 likes
  • 2 in conversation