<?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: Compare two Oracle tables data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544845#M150688</link>
    <description>&lt;P&gt;One possibility is to do a merge: if you use a by statement in the datastep, SAS tells Oracle to serve data in order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, if the variables you want to compare are A,B and C:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vars = a b c;&lt;BR /&gt;%let last_var=%scan(&amp;amp;vars,-1);
data Only1 Only2;
  in1=0; /* by setting these to 0, we catch different number of duplicates */
  in2=0;
  merge 
    oralib1.data_x(keep=&amp;amp;vars in=in1)
    oralib2.data_x(keep=&amp;amp;vars in=in2)
    ;
  by &amp;amp;vars;&lt;BR /&gt;  duplicate=not(first.&amp;amp;last_var and last.&amp;amp;last_var);
  if not in1 then output only2;
  else if not in2 then output only1;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put in the initialization of IN1 and IN2, and the check for duplicates, in case there were duplicates in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If both tables have primary keys, that is not necessary if the primary key variables are part of the variables checked.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2019 13:21:18 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2019-03-21T13:21:18Z</dc:date>
    <item>
      <title>Compare two Oracle tables data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544744#M150657</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to compare two Oracle tables in sas and both these tables are present in the different database. I can't have permission to create the link within Oracle to compare these tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other way in sas to compare these tables other than proc compare?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Japs&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 00:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544744#M150657</guid>
      <dc:creator>japsas100</dc:creator>
      <dc:date>2019-03-21T00:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two Oracle tables data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544745#M150658</link>
      <description>&lt;P&gt;Extracting both tables into SAS and comparing them there would be the simplest way - PROC COMPARE is a great way to do this. Since you can't create a link within Oracle then you can't compare them within either Oracle server.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 00:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544745#M150658</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-03-21T00:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two Oracle tables data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544749#M150660</link>
      <description>&lt;P&gt;you must have permissions to the Oracle tables.&lt;/P&gt;
&lt;P&gt;then you can download the tables and do a SAS compare make sure you enforce some type of a sort order otherwise you may end up with unexpected none compared results that are not what they seem to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example if data set 1 has&lt;/P&gt;
&lt;P&gt;id code&lt;/P&gt;
&lt;P&gt;1 xyz&lt;/P&gt;
&lt;P&gt;and data set 2 has&lt;/P&gt;
&lt;P&gt;id code&lt;/P&gt;
&lt;P&gt;0 xyz&lt;/P&gt;
&lt;P&gt;1 xyz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then your SAS compare will fail unless you use a by ID statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 01:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544749#M150660</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-03-21T01:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two Oracle tables data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544762#M150665</link>
      <description>&lt;P&gt;If you are allowed to upload to oracle, you can copy a table there via SAS and run the comparison there using SQL, if that's what you really want.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 02:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544762#M150665</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-03-21T02:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two Oracle tables data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544823#M150678</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124001"&gt;@japsas100&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to compare two Oracle tables in sas and both these tables are present in the different database. I can't have permission to create the link within Oracle to compare these tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;Is there any other way in sas to compare these tables other than proc compare?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Japs&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not proc compare?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 12:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544823#M150678</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-21T12:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two Oracle tables data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544845#M150688</link>
      <description>&lt;P&gt;One possibility is to do a merge: if you use a by statement in the datastep, SAS tells Oracle to serve data in order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, if the variables you want to compare are A,B and C:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vars = a b c;&lt;BR /&gt;%let last_var=%scan(&amp;amp;vars,-1);
data Only1 Only2;
  in1=0; /* by setting these to 0, we catch different number of duplicates */
  in2=0;
  merge 
    oralib1.data_x(keep=&amp;amp;vars in=in1)
    oralib2.data_x(keep=&amp;amp;vars in=in2)
    ;
  by &amp;amp;vars;&lt;BR /&gt;  duplicate=not(first.&amp;amp;last_var and last.&amp;amp;last_var);
  if not in1 then output only2;
  else if not in2 then output only1;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put in the initialization of IN1 and IN2, and the check for duplicates, in case there were duplicates in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If both tables have primary keys, that is not necessary if the primary key variables are part of the variables checked.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 13:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-Oracle-tables-data/m-p/544845#M150688</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-03-21T13:21:18Z</dc:date>
    </item>
  </channel>
</rss>

