|
Try a correlated query instead of a join:
proc sql;
select *
from main a
where exists (
select 1 from lookup b
where a.num_x between b.beg_num and b.end_num
)
order by id;
quit;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Michael Murff
Sent: Wednesday, March 09, 2011 10:35 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: SQL lookup - more efficient way?
** Hi sas-l;
** my real tables are quite large;
** anybody know how to optimize this using ansi standard SQL syntax? ;
data main;
do id=1 to 10;
num_x=round(100*uniform(123),1); output;
end;
run;
data lookup;
beg_num=1; end_num=10; output;
beg_num=11; end_num=20; output;
beg_num=21; end_num=30; output;
run;
proc sql;
select * from main, lookup
where num_x between beg_num and end_num
order by id;
quit;
endsas;
** thank you in advance;
** Regards, Mike;
|