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-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!

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.

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