<?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: SAS Dataset to Oracle table merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361004#M85083</link>
    <description>&lt;P&gt;You can oracle table through implicit pass through.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table oratable.tablename as&lt;/P&gt;
&lt;P&gt;select *&lt;/P&gt;
&lt;P&gt;from sastable.tablename;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;---Then create index&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;connect to oracle (user=&amp;amp;myid orapw=&amp;amp;mypwd path="&amp;amp;mydb");&lt;BR /&gt;execute ( create index on tablename&amp;nbsp;(columns) ) by oracle; &lt;BR /&gt;disconnect from oracle;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--then do the update with logic you have&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connect to oracle (user=&amp;amp;myid orapw=&amp;amp;mypwd path="&amp;amp;mydb");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;execute ( your update logic goes here)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;by oracle; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;disconnect from oracle;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 24 May 2017 03:39:47 GMT</pubDate>
    <dc:creator>kiranv_</dc:creator>
    <dc:date>2017-05-24T03:39:47Z</dc:date>
    <item>
      <title>SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360847#M85021</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wanted some help in the tuning the below&amp;nbsp;query, which is taking 2 hours to update the Oracle table after Oracle -SAS merge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS datset has 1800 records. Oracle table is pretty big, but indexed on merging variables. after merging it is updating 4000 records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname test&amp;nbsp;oracle user=&amp;amp;myid password=&amp;amp;mypwd path="&amp;amp;mydb" schema=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&amp;nbsp;&lt;BR /&gt;update test.&amp;amp;Oracle_table &amp;nbsp;as a&lt;BR /&gt;set&lt;BR /&gt;test_id&amp;nbsp;=&lt;BR /&gt;(select test_id&amp;nbsp;from sas_dataset as b&lt;BR /&gt;where a.&amp;amp;rec_id = b.&amp;amp;rec_id and a.run_id = b.run_id &amp;nbsp; and a.run_date = b. run_date)&lt;BR /&gt;where exists&lt;BR /&gt;(select * from &lt;SPAN&gt;sas&lt;/SPAN&gt;&lt;SPAN&gt;_dataset&lt;/SPAN&gt; as b&lt;BR /&gt;&lt;SPAN&gt;where a.&amp;amp;rec_id = b.&amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt;rec_id&lt;/SPAN&gt;&lt;SPAN&gt; and a.&lt;/SPAN&gt;&lt;SPAN&gt;run_id&lt;/SPAN&gt;&lt;SPAN&gt; = b.run_id &amp;nbsp; and a.run_date = b. run_date)&lt;/SPAN&gt;&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname test clear;&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;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 17:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360847#M85021</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-05-23T17:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360859#M85022</link>
      <description>&lt;P&gt;As SAS dataset is pretty small. Move the SAS dataset to Oracle and build index on the table and collect stats. Then do the update through explicit pass through.&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>Tue, 23 May 2017 20:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360859#M85022</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-23T20:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360862#M85023</link>
      <description>&lt;P&gt;Given the small size of the SAS dataset, I'd recommend pushing it across to Oracle into a temporary table and doing the full update there locally using explicit SQL passthrough. &amp;nbsp;I've had mixed results using implicit passthrough SQL with Oracle in the past, particularly when I'm trying to join/reference SAS datasets with Oracle tables like you're doing. &amp;nbsp;I always try to push everything into either SAS or Oracle if I can help it. &amp;nbsp;Plus, using explicit SQL passthrough will let you add optimizer hints if needed to make sure it's using the indexes properly (although there are some tricks to that too I can share if you're interested).&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 17:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360862#M85023</guid>
      <dc:creator>Sven111</dc:creator>
      <dc:date>2017-05-23T17:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360869#M85025</link>
      <description>&lt;P&gt;Yes please. I am interested to know that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 18:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360869#M85025</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-05-23T18:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360999#M85082</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this below as per your suggestion of adding option and creating the test table in ORacle DB. &amp;nbsp;But i am getting error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can u please correct my mistake? &amp;nbsp;I needed to create a empty table - so there is no "from".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error - right paranthesis is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options dbidirectexec sastraceloc=saslog;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;connect to oracle (user=&amp;amp;myid orapw=&amp;amp;mypwd path="&amp;amp;mydb");&lt;BR /&gt;execute(&lt;BR /&gt;create table test.post_test as&lt;BR /&gt;select&lt;BR /&gt;(job_id char(10),&lt;BR /&gt;sale_id char(20),&lt;BR /&gt;reason &amp;nbsp;char(2000),&lt;BR /&gt;run_id char(20),&lt;BR /&gt;run_date char(20)&lt;/P&gt;&lt;P&gt;)&lt;BR /&gt;);&lt;BR /&gt;disconnect from oracle;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 02:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/360999#M85082</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-05-24T02:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361004#M85083</link>
      <description>&lt;P&gt;You can oracle table through implicit pass through.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table oratable.tablename as&lt;/P&gt;
&lt;P&gt;select *&lt;/P&gt;
&lt;P&gt;from sastable.tablename;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;---Then create index&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;connect to oracle (user=&amp;amp;myid orapw=&amp;amp;mypwd path="&amp;amp;mydb");&lt;BR /&gt;execute ( create index on tablename&amp;nbsp;(columns) ) by oracle; &lt;BR /&gt;disconnect from oracle;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--then do the update with logic you have&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connect to oracle (user=&amp;amp;myid orapw=&amp;amp;mypwd path="&amp;amp;mydb");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;execute ( your update logic goes here)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;by oracle; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;disconnect from oracle;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 03:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361004#M85083</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-24T03:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361024#M85091</link>
      <description>There have quite a few similar questions on the communities if you care to search. &lt;BR /&gt;One hint though: DBKEY=.</description>
      <pubDate>Wed, 24 May 2017 06:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361024#M85091</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-05-24T06:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361418#M85231</link>
      <description>&lt;P&gt;There were a couple of things that tripped me up on Oracle hinting from Explicit Pass-Through SQL. &amp;nbsp;The first is that by default, SAS strips out any comments from the pass through, and since Oracle hints are passed as comments it won't send them by default. &amp;nbsp;Depending on how you generally connect to Oracle from PROC SQL and what version of SAS you're on this can either be an easy fix or not. &amp;nbsp;If your doing an explicit connection like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;connect to oracle (user=myusr1 password=mypwd1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then you can just add the paramater PRESERVE_COMMENTS:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;connect to oracle as mycon(user=myusr1 password=mypwd1 preserve_comments);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But if you're using something older than SAS 9.2, &lt;A href="http://support.sas.com/techsup/notes/v8/14/208.html" target="_self"&gt;even that won't work&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you generally connect to Oracle via a LIBNAME statement (which is convenient since you can then use the same connection for both implicit and explicit pass-through SQL, there is no available option to enable you to preserve comments.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME OracSAS     ORACLE     USER=&amp;amp;UserNm    PASS=&amp;amp;PassWd   PATH='SASDB'  CONNECTION=GLOBAL   SCHEMA=&amp;amp;UserNm;

PROC SQL;
        CONNECT USING OracSAS AS OracDB;
        ...SQL STUFF...
        DISCONNECT FROM OracDB;
;QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can get around this problem (and the problem with old versions of SAS) by wrapping parts of the comments you want to use in %BQUOTE. &amp;nbsp;I've added the following to my autoexec.sas file and then can just reference the macro vars as needed in my explicit pass-through code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    %LET ORAC_HINT__APPEND      = %BQUOTE(/)%BQUOTE(*)+ APPEND %BQUOTE(*)%BQUOTE(/);
    %LET ORAC_HINT__PARALLEL_16 = %BQUOTE(/)%BQUOTE(*)+ PARALLEL (16) %BQUOTE(*)%BQUOTE(/);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've also archived some papers I've found over the years that have been useful:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.lexjansen.com/nesug/nesug05/io/io8.pdf" target="_self"&gt;http://www.lexjansen.com/nesug/nesug05/io/io8.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/072-2013.pdf" target="_self"&gt;http://support.sas.com/resources/papers/proceedings13/072-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/081-2013.pdf" target="_self"&gt;http://support.sas.com/resources/papers/proceedings13/081-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi28/151-28.pdf" target="_self"&gt;http://www2.sas.com/proceedings/sugi28/151-28.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 22:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361418#M85231</guid>
      <dc:creator>Sven111</dc:creator>
      <dc:date>2017-05-24T22:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361990#M85467</link>
      <description>Thanks Kiran for the detailed steps. It worked very well and improved the processing time.</description>
      <pubDate>Fri, 26 May 2017 15:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361990#M85467</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-05-26T15:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dataset to Oracle table merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361991#M85468</link>
      <description>Thanks for the links and tips , it is really helpful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 26 May 2017 15:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dataset-to-Oracle-table-merge/m-p/361991#M85468</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2017-05-26T15:04:46Z</dc:date>
    </item>
  </channel>
</rss>

