<?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 Re: How to join 2 tables using 'or' condition on key fields? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103318#M9024</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Linlin.&amp;nbsp; I have not used SAS EG (4.2) to create my own code yet. I am using query builder (just learning EG).&amp;nbsp; Do I need to create a 'program' and put the code in it to run? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 May 2012 12:10:55 GMT</pubDate>
    <dc:creator>ncsthbell</dc:creator>
    <dc:date>2012-05-04T12:10:55Z</dc:date>
    <item>
      <title>How to join 2 tables using 'or' condition on key fields?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103316#M9022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using SAS EG 4.2 and pretty new to it.&amp;nbsp; I am trying to use a query builder to join together 2 tables where the key can exist in one or more columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;TableA - col1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-- if TableA.col1 value is in either one of the columns on TableB, I want to join the data, can't figure out how to accomplish this.&lt;/P&gt;&lt;P&gt;TableB - col1, col2 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to join the TableA to TableB if TableA.col1 = (TableB.col1 or TableB.col2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to build the join for TableA.col1 = TableB.col1,&amp;nbsp; then I went into 'Edit' on the join properties and added 'OR TableA.col1 - TableB.col2)&lt;/P&gt;&lt;P&gt;I get syntax errors because it seems to be expecting the&amp;nbsp; operand to be 'AND', so what I wound up with wad:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TableA.col1 = TableB.col1 AND OR&amp;nbsp; TableA.col1 =&amp;nbsp; TableB.col2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions would be greatly appreciated!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 20:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103316#M9022</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2012-05-03T20:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 tables using 'or' condition on key fields?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103317#M9023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;there is a workaround. after run your joins, check the code EG generated:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CREATE TABLE WORK.QUERY_FOR_ONE_0000 AS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SELECT t1.col1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.col1 AS col11,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.col2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM WORK.ONE t1, WORK.TWO t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE (t1.col1 = t2.col1 &lt;SPAN style="color: #ff0000; font-size: 14pt;"&gt;AND&lt;/SPAN&gt; t1.col1 = t2.col2);&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change the "&lt;SPAN style="color: #ff0000;"&gt;AND&lt;/SPAN&gt;" to "&lt;SPAN style="color: #ff0000;"&gt;or&lt;/SPAN&gt;",run the code again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 22:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103317#M9023</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-03T22:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 tables using 'or' condition on key fields?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103318#M9024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Linlin.&amp;nbsp; I have not used SAS EG (4.2) to create my own code yet. I am using query builder (just learning EG).&amp;nbsp; Do I need to create a 'program' and put the code in it to run? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 12:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103318#M9024</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2012-05-04T12:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 tables using 'or' condition on key fields?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103319#M9025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You don't have to create your own code, EG creates the code automaticlly when you use query builder(you can look at the code&amp;nbsp; by clicking "code" tab) ,you only need to modify the code. Please check the attached screenshot. Hope this helps.&amp;nbsp; - Linlin&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11305i9A9661A4DD03827B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="query builder.png" title="query builder.png" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 14:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-join-2-tables-using-or-condition-on-key-fields/m-p/103319#M9025</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-04T14:19:46Z</dc:date>
    </item>
  </channel>
</rss>

