<?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: Help comparing two tables and only outputing if there are differences in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110975#M258965</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is to use the EXCEPT set operator in Proc SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473694.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473694.htm"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either the columns must be in the same order in both tables or you should user the CORRESPONDING keyword&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can get the unmatched records in table first using something like this (untested)&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 firstonly as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select * from first&lt;/P&gt;&lt;P&gt;&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; Except corr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select * from second&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then get the records in the second table not matched in the first by interchanging 'first' and 'second' in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Richard Carson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 Feb 2013 07:03:02 GMT</pubDate>
    <dc:creator>RichardinOz</dc:creator>
    <dc:date>2013-02-16T07:03:02Z</dc:date>
    <item>
      <title>Help comparing two tables and only outputing if there are differences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110973#M258963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I am sort of a novice SAS user. I was wondering what would be the best way to compare the two tables and only output if there were differences in the data from the two table. I tried using the below code but due to my tables having multiple variables that need to be checked. The sort by one variable is not producing the intended results. &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;DATA OT_2_current;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MERGE OT_2_new (IN=T1) OT_2_old (IN=T2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; BY equip_unit_init_cd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF T1 AND NOT T2 THEN OUTPUT OT_2_current;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 19:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110973#M258963</guid>
      <dc:creator>since_92_yahoo_com</dc:creator>
      <dc:date>2013-02-15T19:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help comparing two tables and only outputing if there are differences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110974#M258964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look into proc compare.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 20:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110974#M258964</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-15T20:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help comparing two tables and only outputing if there are differences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110975#M258965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is to use the EXCEPT set operator in Proc SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473694.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473694.htm"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either the columns must be in the same order in both tables or you should user the CORRESPONDING keyword&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can get the unmatched records in table first using something like this (untested)&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 firstonly as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select * from first&lt;/P&gt;&lt;P&gt;&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; Except corr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select * from second&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then get the records in the second table not matched in the first by interchanging 'first' and 'second' in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Richard Carson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Feb 2013 07:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-comparing-two-tables-and-only-outputing-if-there-are/m-p/110975#M258965</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-02-16T07:03:02Z</dc:date>
    </item>
  </channel>
</rss>

