<?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 Joining 3  tables in SAS SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Joining-3-tables-in-SAS-SQL/m-p/450284#M113381</link>
    <description>&lt;P&gt;Dear SAS community, I am trying to create a more elegant code. I want to joint 3 tables have1, have2 and have3. The problem is that have1 table does not have id2 as a variable and first I have to link table have1 and have2. The code below is working but I would like to have a more elegant code because I may want to link more than 3 tables.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want1
        as select *,b.id2
        from have1 as a 
       left join have2  as b on a.id1=b.id1;
create table want2
   as select a.*, b.*
   from want1 as a left join have3 as c
   on a.id2=c.id2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried something like this but it is not working because I do not have id2 in table&amp;nbsp;have1. Could you please let me know what is the most concise code for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want
        as select *,b.id2
        from have1 as a 
       left join have2  as b on a.id1=b.id1
       left join have3 as c on a.id2=c.id2; quit;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Apr 2018 00:46:34 GMT</pubDate>
    <dc:creator>Agent1592</dc:creator>
    <dc:date>2018-04-02T00:46:34Z</dc:date>
    <item>
      <title>Joining 3  tables in SAS SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-3-tables-in-SAS-SQL/m-p/450284#M113381</link>
      <description>&lt;P&gt;Dear SAS community, I am trying to create a more elegant code. I want to joint 3 tables have1, have2 and have3. The problem is that have1 table does not have id2 as a variable and first I have to link table have1 and have2. The code below is working but I would like to have a more elegant code because I may want to link more than 3 tables.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want1
        as select *,b.id2
        from have1 as a 
       left join have2  as b on a.id1=b.id1;
create table want2
   as select a.*, b.*
   from want1 as a left join have3 as c
   on a.id2=c.id2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried something like this but it is not working because I do not have id2 in table&amp;nbsp;have1. Could you please let me know what is the most concise code for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want
        as select *,b.id2
        from have1 as a 
       left join have2  as b on a.id1=b.id1
       left join have3 as c on a.id2=c.id2; quit;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 00:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-3-tables-in-SAS-SQL/m-p/450284#M113381</guid>
      <dc:creator>Agent1592</dc:creator>
      <dc:date>2018-04-02T00:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3  tables in SAS SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-3-tables-in-SAS-SQL/m-p/450286#M113382</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want
  as select *
  from have1 as a 
  left join have2  as b on a.id1=b.id1
  left join have3 as c on b.id2=c.id2
  ; 
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Apr 2018 01:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-3-tables-in-SAS-SQL/m-p/450286#M113382</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-04-02T01:59:18Z</dc:date>
    </item>
  </channel>
</rss>

