<?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: SQL joins in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172953#M33224</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data table_A;&lt;BR /&gt;input cost;&lt;BR /&gt;id+1;&lt;BR /&gt;datalines;&lt;BR /&gt;1000&lt;BR /&gt;1020&lt;BR /&gt;1100&lt;BR /&gt;345&lt;BR /&gt;5678&lt;BR /&gt;12670&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Table_B;&lt;BR /&gt;input cost;&lt;BR /&gt;id+1;&lt;BR /&gt;datalines;&lt;BR /&gt;1150&lt;BR /&gt;970&lt;BR /&gt;2345&lt;BR /&gt;700&lt;BR /&gt;5500&lt;BR /&gt;11000&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select b.cost from table_b b inner join table_a a&lt;/P&gt;&lt;P&gt;on b.id=a.id&lt;/P&gt;&lt;P&gt;and abs(b.cost-a.cost)&amp;lt;=150;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 23 Aug 2014 21:53:42 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-08-23T21:53:42Z</dc:date>
    <item>
      <title>SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172952#M33223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've a table like below. I need to compare the tables (Table A &amp;amp; Table B) and I need to display the output only if table B value is plus or minus 150 when it is compared with the respective record of Table A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this task with inner join and similar stuff but it never helped. Please suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table A:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cost&lt;/P&gt;&lt;P&gt;1000&lt;/P&gt;&lt;P&gt;1020&lt;/P&gt;&lt;P&gt;1100&lt;/P&gt;&lt;P&gt;345&lt;/P&gt;&lt;P&gt;5678&lt;/P&gt;&lt;P&gt;12670&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table B:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cost&lt;/P&gt;&lt;P&gt;1150&lt;/P&gt;&lt;P&gt;970&lt;/P&gt;&lt;P&gt;2345&lt;/P&gt;&lt;P&gt;700&lt;/P&gt;&lt;P&gt;5500&lt;/P&gt;&lt;P&gt;11000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the output like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cost&lt;/P&gt;&lt;P&gt;1150&lt;/P&gt;&lt;P&gt;970&lt;/P&gt;&lt;P&gt;5500&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Aug 2014 15:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172952#M33223</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-08-23T15:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172953#M33224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data table_A;&lt;BR /&gt;input cost;&lt;BR /&gt;id+1;&lt;BR /&gt;datalines;&lt;BR /&gt;1000&lt;BR /&gt;1020&lt;BR /&gt;1100&lt;BR /&gt;345&lt;BR /&gt;5678&lt;BR /&gt;12670&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Table_B;&lt;BR /&gt;input cost;&lt;BR /&gt;id+1;&lt;BR /&gt;datalines;&lt;BR /&gt;1150&lt;BR /&gt;970&lt;BR /&gt;2345&lt;BR /&gt;700&lt;BR /&gt;5500&lt;BR /&gt;11000&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select b.cost from table_b b inner join table_a a&lt;/P&gt;&lt;P&gt;on b.id=a.id&lt;/P&gt;&lt;P&gt;and abs(b.cost-a.cost)&amp;lt;=150;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Aug 2014 21:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172953#M33224</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-08-23T21:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172954#M33225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Operations that depend on the order of observations are simpler to do with datasteps. If you don't want to generate Id's, do as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data table_A;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input cost;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1020&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;345&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5678&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;12670&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data Table_B;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input cost;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1150&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;970&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2345&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;700&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5500&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;11000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data Table_C;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set Table_A(rename=cost=cost_A);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set Table_B;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if abs(cost-cost_A) &amp;lt;= 150;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop cost_A;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note, 5500 is not part of the result set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Aug 2014 03:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-joins/m-p/172954#M33225</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-08-24T03:56:43Z</dc:date>
    </item>
  </channel>
</rss>

