Date: Tue, 5 Mar 2002 16:14:59 +1000
Reply-To: Peter Baade <Peter_Baade@HEALTH.QLD.GOV.AU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Baade <Peter_Baade@HEALTH.QLD.GOV.AU>
Subject: SQL logic
Content-Type: multipart/mixed;
Hi
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 :-)
Peter.
**********************************************************************
This e-mail, including any attachments sent with it, is confidential
and for the sole use of the intended recipient(s). This confidentiality
is not waived or lost if you receive it and you are not the intended
recipient(s), or if it is transmitted/ received in error.
Any unauthorised use, alteration, disclosure, distribution or review
of this e-mail is prohibited. It may be subject to a statutory duty of
confidentiality if it relates to health service matters.
If you are not the intended recipient(s), or if you have received this
e-mail in error, you are asked to immediately notify the sender by
telephone or by return e-mail. You should also delete this e-mail
message and destroy any hard copies produced.
**********************************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY style="FONT: 8pt MS Sans Serif; MARGIN-LEFT: 2px; MARGIN-TOP: 2px">
<DIV>Hi </DIV>
<DIV> </DIV>
<DIV><FONT size=1>I have three datasets, each with a unique ID variable
(IDVAR).</FONT></DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>I was using SQL to join these, but if I use the where statement </DIV>
<DIV>IF A.IDVAR=B.IDVAR AND A.IDVAR=C.IDVAR </DIV>
<DIV>then only those records with data in each dataset are pulled out.</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>Thanks for any advice, and my apologies if I've missed some important piece
of information in the above question :-)</DIV>
<DIV> </DIV>
<DIV>Peter.</DIV>
<DIV> </DIV></BODY></HTML>
|