Date: Mon, 4 Aug 2008 12:50:26 -0700
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject: Re: SAS SQL Question
In-Reply-To: A<1ca751e30808041127q1b62982axbbc0f483b418bbeb@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
Here are a couple of corollaries (SQL and datastep):
(the MERGE allows just the list of letters, if less
code is what you are after instead of repeated LEFT
JOINs and ONs)
data a;
id=1;a=1;output;
id=2;a=2;output;
id=3;a=3;output;
id=4;a=4;output;
run;
data b;
id=1;b=1;output;
id=2;b=2;output;
id=3;b=3;output;
id=4;b=4;output;
run;
data c;
id=1;c=1;output;
id=2;c=2;output;
id=3;c=3;output;
id=4;c=4;output;
run;
proc sql;
create table test1 as
select *
from a
left join b
on a.id eq b.id
left join c
on a.id eq c.id
;
quit;
data test2;
merge a(in=in_a) b c;
by id;
if in_a;
run;
proc compare data=test1 compare=test2;
run;
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst
Investment Management & Research
Russell Investments
Russell Investments
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
sudip chatterjee
Sent: Monday, August 04, 2008 11:27 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: SAS SQL Question
Dear Users,
I have sixteen table A-P,
I want to do left join, like my main table is table A
So, A left join B I get AB then left join C I get ABC etc
I am trying to get a short code for this, also can it be done at one
time in proc sql ?
I appreciate all of your time
Regards