data sample;
input company$ sic roe ta;
datalines;
AA 100 5.5 100
BB 100 5.6 200
CC 200 6.5 300
DD 400 5.8 300
EE 400 8.9 500
;
run;
proc print data=sample;
run;
data control;
input company$ sic roe ta;
datalines;
XX 100 5.4 100
YY 100 5.9 200
DE 100 5.6 200
RR 200 6.4 300
RE 200 7.5 400
RT 300 6.5 450
TT 400 5.9 300
TR 400 9.8 500
;
run;
proc print data=Control;
run;
proc sql;
create table want as
select a.*, b.company as control, b.roe as control_roe, b.ta as control_ta
from sample as a
left join control as b
on a.sic=b.sic
and (a.roe-b.roe)/a.roe between -0.5 and 0.7
and (a.ta - b.ta)/a.ta between -.02 and 0.2; /*0.2 is 20%*/
quit;
proc print data=want;
run; I have run the above code and found the following: The SAS System
Obs company sic roe ta control control_roe control_ta
1 AA 100 5.5 100 XX 5.4 100
2 BB 100 5.6 200 YY 5.9 200
3 CC 200 6.5 300 RR 6.4 300
4 DD 400 5.8 300 TT 5.9 300
5 EE 400 8.9 500 TR 9.8 500 But I want, for example, for company BB, match companies will be YY and DE. That codes give me only YY for BB. How can I have both YY and DE for BB. Thank you for your efforts.
... View more