If I understand the SQL query properly, you want to create a table
containing all variables from TABLE1 for observations from TABLE1 which
match on COLUMN_NAME to TABLE2.
I haven't used the EXIST condition before, but couldn't the query be
re-written like this?
create table new as
from table1 a, table2 b
where a.column_name = b.column_name
If you want to use a DATA step merge, both data sets will have to be
sorted or indexed on the variable used to merge.
Proc sort data = table1;
Proc sort data = table2 (keep=column_name);
Merge table1 (in=a) table2 (in=b);
If a and b;
Center for Health Program Development and Management
University of Maryland, Baltimore County
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Wednesday, April 25, 2007 1:02 AM
Subject: convert proc sql to data step
Can u please help in converting the below code to SAS data step
the performance of this code buggs...it takes nearly 20 mins...
the size of the table is
table1 45000 records.
table2 25000 records.
create table new as select * from table1 a where exists
(select 1 from table2 b where b.column_name = a.column_name);
thanks in advance,]