LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 25 Apr 2007 09:15:57 -0400
Reply-To:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:   Re: convert proc sql to data step
Comments:   To: "boobeshgroups@gmail.com" <boobeshgroups@GMAIL.COM>
In-Reply-To:   A<1177477292.792573.231390@b40g2000prd.googlegroups.com>
Content-Type:   text/plain; charset="us-ascii"

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?

proc sql; create table new as select a.* from table1 a, table2 b where a.column_name = b.column_name ; quit;

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; By column_name; Run;

Proc sort data = table2 (keep=column_name); By column_name; Run;

Data new; Merge table1 (in=a) table2 (in=b); By column_name; If a and b; Run;

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of boobeshgroups@gmail.com Sent: Wednesday, April 25, 2007 1:02 AM To: SAS-L@LISTSERV.UGA.EDU Subject: convert proc sql to data step

hi , Can u please help in converting the below code to SAS data step code... the performance of this code buggs...it takes nearly 20 mins... the size of the table is table1 45000 records. table2 25000 records.

proc sql; create table new as select * from table1 a where exists (select 1 from table2 b where b.column_name = a.column_name); quit;

thanks in advance,]


Back to: Top of message | Previous page | Main SAS-L page