|Date: ||Tue, 5 Mar 2002 13:00:39 -0500|
|Reply-To: ||Francis Harvey <HARVEYF1@WESTAT.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Francis Harvey <HARVEYF1@WESTAT.COM>|
|Subject: ||Re: SQL logic|
|Content-Type: ||text/plain; charset="iso-8859-1"|
I would expect the following code to work:
select a.idvar as a, b.idvar as b, c.idvar as c
from a left join b
on a.idvar = b.idvar
left join c
on a.idvar = c.idvar;
Francis R. Harvey III
VB programmers know the wisdom of Nothing
> -----Original Message-----
> From: Peter Baade [mailto:Peter_Baade@HEALTH.QLD.GOV.AU]
> Sent: Tuesday, March 05, 2002 1:15 AM
> To: SAS-L@LISTSERV.VT.EDU
> Subject: SQL logic
> I have three datasets, each with a unique ID variable (IDVAR).
> The first dataset (A) has one record for each person. The
> second and third datasets (B and C) have one record per
> person, but not necessarily for all people.
> I was using SQL to join these, but if I use the where statement
> IF A.IDVAR=B.IDVAR AND A.IDVAR=C.IDVAR
> then only those records with data in each dataset are pulled out.
> So, pulling out a paper by Christina Williams (Proc SQL for
> Data step die hards), I find that using a LEFT JOIN would be
> better logic. However, it seems as if this only works for two
> datasets, not three.
> Is there some trival SQL procedure that does what I want? Its
> more the logic that I'm trying to find, not necessarily the
> specific code.
> Thanks for any advice, and my apologies if I've missed some
> important piece of information in the above question :-)