Date: Thu, 29 Nov 2001 05:34:50 -0600
Reply-To: Willy Waks <wwaks@ti.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Willy Waks <wwaks@TI.COM>
Organization: Texas Instruments
Subject: SQL full join vs DATA step merge
Folks:
Although I remember having seen discussions about it, I cannot find an
example of the SQL code equivalent to a Data Step Merge.
I want to convert:
DATA COMBINED;
MERGE A B C;
BY VAR1 VAR2 VAR3;
RUN;
My code:
PROC SQL NOPRINT;
CREATE TABLE COMBINED AS
Select *
FROM A
FULL JOIN B
ON A.VAR1=B.VAR1
AND A.VAR2=B.VAR1
AND A.VAR3=B.VAR3
FULL JOIN C
ON A.VAR1=C.VAR1
AND A.VAR2=C.VAR1
AND A.VAR3=C.VAR3
;
These two pieces of code do not yield the same number of obs., and my SQL
code gives me a lot of missing BY varaiables.
Somehow, it seems I need to use the COALESCE function, but it is still
obscure to me.
Any help is appreciated
Thanks you,
Willy Waks
Dallas
|