BookmarkSubscribeRSS Feed
mei
Calcite | Level 5 mei
Calcite | Level 5

Dear Sir,

I have 2 datasets, original_599 and balance_9981.(original_599 dataset has n=599 firms/ years and balance_9981 dataset has n=9981 firms/.years).

I need to find 599 firms from the 9981 firms to match with the original_599 dataset based on their industry (ffind) and size (size).

The different characteristics of original_599 is CEOturn=1 while balance_9981 CEOturn=0.  (Ceoturn=Ceo turnover)

I wish to have 2 options:

a) those firms matched are from the same financial year (fyear)

b) no need to match same financial year (as they may not be able to find the suitable one).

Thanks.

2 REPLIES 2
LinusH
Tourmaline | Level 20

First match on Fiscal Year.

The in the next loop match without Fiscal Year, but exclude the ones that already have a match...?

Data never sleeps
mei
Calcite | Level 5 mei
Calcite | Level 5

I have tried using this - for the same financial year. What is your view?

proc sort data=huang_599;

by gvkey fyear;

run;

proc sort data=huang_bal;

by gvkey fyear;

run;

proc sql;

create table control as

select O.*, A.gvkey as Anum, A.fyear as Afy, abs(O.size-A.size) as sizeDiff

from huang_bal as O inner join huang_599 as A

     on O.fYear=A.fyear and O.ffind=A.ffind

where O.gvkey not in (select gvkey from huang_599)

    order by gvkey;

   

proc sort data=control;

by anum afy;

run;

/* Find the 1 set of 599 closest firms  */

proc means data=control noprint;

by Anum afy;

output out=selected idgroup(min(sizeDiff) out[1] (fyear gvkey)=);

run;

proc sql;

create table selected1 as

select a.*, b.*

from selected a left join  huang_bal b

on a.gvkey=b.gvkey and a.fyear=b.fYear

order by a.gvkey, a.fyear;

run;

data selected1;

set selected1;

drop _freq_ _type_;

run;

**599**;

data combined;

set huang_599 selected1;

run;

**1198**;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2303 views
  • 1 like
  • 2 in conversation