It is not that bad. But the join lightly beats a subquery. The inner join is the best.
data a;
do id=1 to 1e6;
price=id;
output;
output;
end;
run;
data b;
do id=100000 to 200000;
output;
end;
run;
proc sql _method stimer;
create table temp as
select id,
sum(price) as income
from a
where id in (select id from b)
;
quit;
proc sql _method stimer;
create table temp as
select b.id, sum(price) as income
from b left join a on
b.id=a.id;
quit;
proc sql _method stimer;
create table temp as
select b.id, sum(price) as income
from b inner join a on
b.id=a.id;
quit;
|