<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to join three tables using proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80205#M23091</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a silly question. I want to full join three tables using proc sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following, but doesn't work. I wonder what's wrong with the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table new as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from a full join b full join c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.id = b.id = c.id;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 08:19:17 GMT</pubDate>
    <dc:creator>SeanZ</dc:creator>
    <dc:date>2013-07-16T08:19:17Z</dc:date>
    <item>
      <title>How to join three tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80205#M23091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a silly question. I want to full join three tables using proc sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following, but doesn't work. I wonder what's wrong with the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table new as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from a full join b full join c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.id = b.id = c.id;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 08:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80205#M23091</guid>
      <dc:creator>SeanZ</dc:creator>
      <dc:date>2013-07-16T08:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to join three tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80206#M23092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the tables all have the same structure?&amp;nbsp; This will make a difference as to which approach to take, but if ID is the only common variable then the code you need is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table new as select *&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; full join&lt;/P&gt;&lt;P&gt;&amp;nbsp; b &lt;/P&gt;&lt;P&gt;&amp;nbsp; on a.id=b.id&lt;/P&gt;&lt;P&gt;&amp;nbsp; full join&lt;/P&gt;&lt;P&gt;&amp;nbsp; c &lt;/P&gt;&lt;P&gt;&amp;nbsp; on b.id=c.id&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will get 2 warning messages saying that variable id already exists, due to the lazy approach of using select *.&amp;nbsp; You'll get the same message for any other variables that exist in more than one dataset, in which case you should explicitly list the variables and table source in the select statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80206#M23092</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2013-07-16T12:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to join three tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80207#M23093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a case like this you should provide the log.&lt;/P&gt;&lt;P&gt;When you say it does not work - do you get an error, or just not what you expected?&lt;/P&gt;&lt;P&gt;And stab in the dark - are a.id, b.id and c.id all of the same type (numeric or character)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80207#M23093</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-07-16T12:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to join three tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80208#M23094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In answer to your question "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;what's wrong with the code&lt;/SPAN&gt;", looking at the documentation for joining tables in SQL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p1bk7i6jqseje7n1lifcip8kzhpp.htm" title="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p1bk7i6jqseje7n1lifcip8kzhpp.htm"&gt;SAS(R) 9.3 SQL Procedure User's Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like the full join is for &lt;STRONG&gt;two tables&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"A full outer join, specified with the keywords FULL JOIN and ON, has all the rows from the Cartesian product of the &lt;STRONG&gt;two tables&lt;/STRONG&gt; for which the SQL expression is true, plus rows from each table that do not match any row in the other table."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will need to modify your approach if you want to join 3 tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80208#M23094</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-07-16T12:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to join three tables using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80209#M23095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. The log said missing an "ON" and statement will be ignored.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 19:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-three-tables-using-proc-sql/m-p/80209#M23095</guid>
      <dc:creator>SeanZ</dc:creator>
      <dc:date>2013-07-16T19:38:10Z</dc:date>
    </item>
  </channel>
</rss>

