<?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: Oracle SQL to SAS Translation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272729#M54281</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79805"&gt;@buechler66&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The table Compare_Error looks like this (see attached).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The relevant tables are the other two. One of them needs to have a column called ROWID for this query to be at least syntactically correct.&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2016 13:32:43 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-05-24T13:32:43Z</dc:date>
    <item>
      <title>Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272705#M54273</link>
      <description>&lt;P&gt;Hi. I need some help trying to translate this where condition from Oracle SQL to a valid SAS equivelant. &amp;nbsp;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A.ROWID IN (SELECT TABLE_ROWID FROM IV_RPT.COMPARE_ERROR)&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The complete Proc SQL I'm trying to run:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table QueryData400 as         
select 'UNIDENTIFIED DISCREPENCY' as RULE_NM length = 58,
          b.actual_dlvry_date as AD_DT,                 
          b.imb_code length = 31,                 
          400 as RULE_ORDER,
          b.spm_calc_batch_date         
from iv_ora.bi_spm_piece_recon a,  bids_ora.bi_spm_piece_recon b         &lt;BR /&gt;where a.imb_code = b.imb_code 
  and intck('day',a.spm_calc_batch_date,b.spm_calc_batch_date) &amp;lt;= 45 
  and ROWID IN (SELECT TABLE_ROWID
                FROM iv_ora.COMPARE_ERROR);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error I'm getting:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;5   + proc sql;
5   +               create table QueryData400 as         select 'UNIDENTIFIED DISCREPENCY' as RULE_NM length = 58,
    b.actual_dlvry_date as AD_DT,                 b.imb_code length = 31,                 400 as RULE_ORDER,
6   + b.spm_calc_batch_date         from iv_ora.bi_spm_piece_recon a,  bids_ora.bi_spm_piece_recon b         where a.imb_code
= b.imb_code           and intck('day',a.spm_calc_batch_date,b.spm_calc_batch_date) &amp;lt;= 45           and ROWID IN (SELECT
TABLE_ROWID
7   + FROM iv_ora.COMPARE_ERROR);
ERROR: The following columns were not found in the contributing tables: ROWID.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
7   +                                 quit;
NOTE: The SAS System stopped processing this step because of errors.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 12:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272705#M54273</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-24T12:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272707#M54274</link>
      <description>&lt;P&gt;Assuming ROWID is a variable, and not an automatic incrementor (its never a good idea to use row position as a comparitor) then you could try something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have1 (in=a) have2 (in=b);
  by rowid;
  if a and b;
run;&lt;/PRE&gt;
&lt;P&gt;I.e. if the rowid is in both the base dataset and the IN dataset. &amp;nbsp;Note that SAS doesn't have that type of in where clause, you need to merge them, or you could do it with hash, but why complicate things?&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 12:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272707#M54274</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-24T12:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272719#M54277</link>
      <description>No, it's not a variable I created. It's an Oracle SQL system variable. I don't have control over the Oracle SQL code, it's just my requirement to replicated it in SAS. I'm stumped. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Tue, 24 May 2016 13:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272719#M54277</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-24T13:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272721#M54278</link>
      <description>&lt;P&gt;There is no column ROWID in either iv_ora.bi_spm_piece_recon or bids_ora.bi_spm_piece_recon.&lt;/P&gt;
&lt;P&gt;Inspect the data so you find which column to use.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272721#M54278</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-24T13:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272722#M54279</link>
      <description>&lt;P&gt;The table Compare_Error looks like this (see attached).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12576i88703C0F48E5E991/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;</description>
      <pubDate>Tue, 24 May 2016 13:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272722#M54279</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-24T13:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272728#M54280</link>
      <description>&lt;P&gt;As I mentioned before, row number automatic variables are not a good idea to code with - if you sort that data you may get a different result. &amp;nbsp;You could I suppose passthrough the code:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  connect to oracle (path=...);
  select * 
  from  connection to oracle (
    &amp;lt;insert your oracle sql here&amp;gt;
  );
  disconnect from oracle;
quit;&lt;/PRE&gt;
&lt;P&gt;What that does is pass the sql you have from OC, through to the database, so that code natively executes, the result of that query can then be selected from in the outer block.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272728#M54280</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-24T13:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272729#M54281</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79805"&gt;@buechler66&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The table Compare_Error looks like this (see attached).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The relevant tables are the other two. One of them needs to have a column called ROWID for this query to be at least syntactically correct.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272729#M54281</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-24T13:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272730#M54282</link>
      <description>&lt;P&gt;ROWID is a bit like _n_ in thats implicit in a table.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272730#M54282</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-24T13:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle SQL to SAS Translation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272733#M54283</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;ROWID is a bit like _n_ in thats implicit in a table.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Ah, I see. Would not use it, but a real identifier instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the column ROWID should be created when importing the tables into SAS, with the contents of of the Oracle pseudocolumn.&lt;/P&gt;
&lt;P&gt;That should then make it safe.&lt;/P&gt;
&lt;P&gt;Or, if the whole logic runs in SAS, creating a ROWID initially from _N_ could accomplish the same task.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-SQL-to-SAS-Translation/m-p/272733#M54283</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-24T13:45:05Z</dc:date>
    </item>
  </channel>
</rss>

