<?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: extremely slow PROC SQL with a CREATE TABLE with join to a local library in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12294#M1622</link>
    <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
Below some example code illustrating Doc's first option.&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
connect to oracle;&lt;BR /&gt;
&lt;BR /&gt;
/* load SAS table into temporary ORACLE table */&lt;BR /&gt;
execute(&lt;BR /&gt;
select *&lt;BR /&gt;
into #mytemp&lt;BR /&gt;
from mytable&lt;BR /&gt;
) by sqlsvr;&lt;BR /&gt;
&lt;BR /&gt;
/* join tables and return result set to SAS */&lt;BR /&gt;
create table myresult as&lt;BR /&gt;
select *&lt;BR /&gt;
from connection to sqlsvr&lt;BR /&gt;
(&lt;BR /&gt;
select *&lt;BR /&gt;
from #mytemp as a&lt;BR /&gt;
join someothertable as b&lt;BR /&gt;
on a.key = b.key&lt;BR /&gt;
);&lt;BR /&gt;
&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Found under: &lt;A href="http://www.mathkb.com/Uwe/Forum.aspx/sas/44759/Insert-in-to-temporary-table-for-SQL-pass-through-query" target="_blank"&gt;http://www.mathkb.com/Uwe/Forum.aspx/sas/44759/Insert-in-to-temporary-table-for-SQL-pass-through-query&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
    <pubDate>Wed, 06 Oct 2010 06:38:34 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2010-10-06T06:38:34Z</dc:date>
    <item>
      <title>extremely slow PROC SQL with a CREATE TABLE with join to a local library</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12292#M1620</link>
      <description>I'm running SAS 9.1 for Windows in an XP environment in a large enterprise with Oracle.  I'm a new SAS user and have learned most of what I know from this forum and have a major performance problem I haven't been able to solve.  When running a proc sql script to with a create table with a table join in a local library, the performance is EXTREMELY slow (over 10 minutes to return 8 rows with 5 columns).  Whenever I query for a more general dataset without a local join the query completes in just seconds however returns far more data than needed and at times difficult to determine why cases were omitted from the results set.  Are there options to improve performance in an Win XP environment when joined to a local table to restrict results to the dataset I import?  Thanks in advance for your help!</description>
      <pubDate>Tue, 05 Oct 2010 18:33:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12292#M1620</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-10-05T18:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: extremely slow PROC SQL with a CREATE TABLE with join to a local library</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12293#M1621</link>
      <description>When you are joining to a local table, SAS has to bring the entire Oracle table to the SAS server to perform the join.  Ouch!  Here are three solutions I have seen used.&lt;BR /&gt;
&lt;BR /&gt;
1) write a table to the Oracle database with your local data.  Most DBA's are loath to let "us" do that, but some will do it for a decision support server.&lt;BR /&gt;
&lt;BR /&gt;
2) do a select against the Oracle table to reduce the amount of data, bringing that to the SAS Server for the join.&lt;BR /&gt;
&lt;BR /&gt;
3) write code so that your 'small table' is passed to Oracle as fixed text in the query.  This works well when the join is based on a key field like "ID" and you can put it into a macro variable for an "IN" operator in the join.</description>
      <pubDate>Tue, 05 Oct 2010 18:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12293#M1621</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-10-05T18:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: extremely slow PROC SQL with a CREATE TABLE with join to a local library</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12294#M1622</link>
      <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
Below some example code illustrating Doc's first option.&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
connect to oracle;&lt;BR /&gt;
&lt;BR /&gt;
/* load SAS table into temporary ORACLE table */&lt;BR /&gt;
execute(&lt;BR /&gt;
select *&lt;BR /&gt;
into #mytemp&lt;BR /&gt;
from mytable&lt;BR /&gt;
) by sqlsvr;&lt;BR /&gt;
&lt;BR /&gt;
/* join tables and return result set to SAS */&lt;BR /&gt;
create table myresult as&lt;BR /&gt;
select *&lt;BR /&gt;
from connection to sqlsvr&lt;BR /&gt;
(&lt;BR /&gt;
select *&lt;BR /&gt;
from #mytemp as a&lt;BR /&gt;
join someothertable as b&lt;BR /&gt;
on a.key = b.key&lt;BR /&gt;
);&lt;BR /&gt;
&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Found under: &lt;A href="http://www.mathkb.com/Uwe/Forum.aspx/sas/44759/Insert-in-to-temporary-table-for-SQL-pass-through-query" target="_blank"&gt;http://www.mathkb.com/Uwe/Forum.aspx/sas/44759/Insert-in-to-temporary-table-for-SQL-pass-through-query&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 06 Oct 2010 06:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12294#M1622</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-10-06T06:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: extremely slow PROC SQL with a CREATE TABLE with join to a local library</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12295#M1623</link>
      <description>If Doc’s first option is not possible, in my experience, Doc’s third option usually works well.  If you do go with option 3, I highly recommend that you also utilize an Oracle hint to ensure that Oracle uses the correct index.  When I have left off the Oracle hint, I have had cases where a particular step executes in less than 10 seconds one day and more than 10 minutes the next.  Here is a useful paper that contains information on identifying and using Oracle indexes, as well as many other tips on using SAS to extract data from Oracle databases:  &lt;A href="http://www.nesug.org/proceedings/nesug05/io/io8.pdf" target="_blank"&gt;www.nesug.org/proceedings/nesug05/io/io8.pdf&lt;/A&gt;&lt;BR /&gt;
  &lt;BR /&gt;
Here is some sample code that illustrates option three.  The code assumes that ORALIB.ORATBL is an oracle table, SASLIB.SASTBL is a local table, the two tables are being merged together based on the variable VBL, and the ORATBL table contains an index VBL_INDX that uses VBL as a key variable:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC SQL NOPRINT;&lt;BR /&gt;
	SELECT VBL INTO: VBL_VALUES SEPARATED BY '", "'&lt;BR /&gt;
	FROM SASLIB.SASTBL;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
DATA SASLIB.MERGED_TBL;&lt;BR /&gt;
	SET ORALIB.ORATBL (ORHINTS='/*+ INDEX(ORATBL, VBL_INDX) */');&lt;BR /&gt;
	WHERE VBL IN ("&amp;amp;VBL_VALUES");&lt;BR /&gt;
RUN;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 06 Oct 2010 10:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/extremely-slow-PROC-SQL-with-a-CREATE-TABLE-with-join-to-a-local/m-p/12295#M1623</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2010-10-06T10:39:32Z</dc:date>
    </item>
  </channel>
</rss>

