<?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: Proc SQL: Where with IN freezes SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38405#M9845</link>
    <description>When I want to include some SAS data into an Oracle extract, I first build a temporary Oracle table and include that as part of the extract syntax.  It's probably gives better performance as well.  Code below.&lt;BR /&gt;
&lt;BR /&gt;
libname dw oracle user=userid&lt;BR /&gt;
                  password=pw&lt;BR /&gt;
                  path="@tns:xyx, buffsize=5000";&lt;BR /&gt;
&lt;BR /&gt;
             **Upload temptable to Oracle;&lt;BR /&gt;
data dw.temptable;&lt;BR /&gt;
   set temptable;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
     connect to oracle&lt;BR /&gt;
     (user=userid orapw=pw path="@tns:xyx, buffsize=5000");&lt;BR /&gt;
                  **Analyze Oracle table for optimization purposes;&lt;BR /&gt;
execute( analyze table temptable estimate statistics sample 1 percent) by oracle;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Be sure to delete the temp table when done.&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
     connect to oracle&lt;BR /&gt;
     (user=userid orapw=pw path="@tns:xyx, buffsize=5000");&lt;BR /&gt;
&lt;BR /&gt;
     execute (drop table temptable) by oracle;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;</description>
    <pubDate>Mon, 11 Jan 2010 14:46:22 GMT</pubDate>
    <dc:creator>Bill</dc:creator>
    <dc:date>2010-01-11T14:46:22Z</dc:date>
    <item>
      <title>Proc SQL: Where with IN freezes SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38402#M9842</link>
      <description>Trying to join a SAS dataset to an Oracle table. This works ALMOST all the time. But whenever we try to use a SELECT against the dataset with an IN clause, the system hangs and SAS never returns.  We can use that same SAS dataset in a join and it works find.  Any ideas are appreciated.&lt;BR /&gt;
&lt;BR /&gt;
This code works:&lt;BR /&gt;
/* build a libname to read Oracle as if it were a SAS dataset */&lt;BR /&gt;
libname teddblib oracle user=us025580 password=Mavfh10 path='Lunar_gdwp1' schema='dm4';&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
	select S.PROFIT_CENTER_ABBR_NM&lt;BR /&gt;
	, s.tyco_electronics_corp_part_nbr&lt;BR /&gt;
    ,sum( S.S_CNST_SHIPPED_LOC_CRNC_AMT) format=DOLLAR12. &lt;BR /&gt;
	from teddblib.DM4133_COSTED_SALES_SMRS_V s&lt;BR /&gt;
	join saspartds sasdb /* sas dataset */&lt;BR /&gt;
		on s.tyco_electronics_corp_part_nbr=sasdb.part_number&lt;BR /&gt;
	group by s.profit_center_abbr_nm&lt;BR /&gt;
	, s.tyco_electronics_corp_part_nbr;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
This code works:&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select part_number from saspartds;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So why won't this code work??? This code freezes SAS with hourglass and never returns:&lt;BR /&gt;
/* build a libname to read Oracle as if it were a SAS dataset */&lt;BR /&gt;
libname teddblib oracle user=us025580 password=Mavfh10 path='Lunar_gdwp1' schema='dm4';&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
	select S.PROFIT_CENTER_ABBR_NM&lt;BR /&gt;
	, s.tyco_electronics_corp_part_nbr&lt;BR /&gt;
    ,sum( S.S_CNST_SHIPPED_LOC_CRNC_AMT) format=DOLLAR12. &lt;BR /&gt;
	from teddblib.DM4133_COSTED_SALES_SMRS_V s&lt;BR /&gt;
	where s.tyco_electronics_corp_part_nbr&lt;BR /&gt;
		in (select part_number from saspartds)&lt;BR /&gt;
	group by s.profit_center_abbr_nm&lt;BR /&gt;
	, s.tyco_electronics_corp_part_nbr;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
In all of the above example, the SAS dataset is a simple dataset created with the code below:&lt;BR /&gt;
/* build a temporary SAS dataset */&lt;BR /&gt;
data work.saspartds;&lt;BR /&gt;
   length part_number $18 saspartinfo $10;&lt;BR /&gt;
   input part_number $ saspartinfo $;&lt;BR /&gt;
cards;&lt;BR /&gt;
6651816-1 infoon6651816-1&lt;BR /&gt;
1740259-1 infoon1740259-1&lt;BR /&gt;
;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 08 Jan 2010 18:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38402#M9842</guid>
      <dc:creator>BarryParish</dc:creator>
      <dc:date>2010-01-08T18:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: Where with IN freezes SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38403#M9843</link>
      <description>Have you tried this with a very small SAS table.  I'm not sure why it would hang with the ORACLE table other than it running the subquery for each observation in the SAS table and it taking a very long time.</description>
      <pubDate>Fri, 08 Jan 2010 19:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38403#M9843</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-01-08T19:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: Where with IN freezes SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38404#M9844</link>
      <description>I agree with Flip.  The code that runs reads the Oracle table just once and transfers it to the SAS server for joining with the SAS table.  The IN clause reads the Oracle table once for EACH observation in the SAS table.</description>
      <pubDate>Sun, 10 Jan 2010 16:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38404#M9844</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-01-10T16:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: Where with IN freezes SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38405#M9845</link>
      <description>When I want to include some SAS data into an Oracle extract, I first build a temporary Oracle table and include that as part of the extract syntax.  It's probably gives better performance as well.  Code below.&lt;BR /&gt;
&lt;BR /&gt;
libname dw oracle user=userid&lt;BR /&gt;
                  password=pw&lt;BR /&gt;
                  path="@tns:xyx, buffsize=5000";&lt;BR /&gt;
&lt;BR /&gt;
             **Upload temptable to Oracle;&lt;BR /&gt;
data dw.temptable;&lt;BR /&gt;
   set temptable;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
     connect to oracle&lt;BR /&gt;
     (user=userid orapw=pw path="@tns:xyx, buffsize=5000");&lt;BR /&gt;
                  **Analyze Oracle table for optimization purposes;&lt;BR /&gt;
execute( analyze table temptable estimate statistics sample 1 percent) by oracle;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Be sure to delete the temp table when done.&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
     connect to oracle&lt;BR /&gt;
     (user=userid orapw=pw path="@tns:xyx, buffsize=5000");&lt;BR /&gt;
&lt;BR /&gt;
     execute (drop table temptable) by oracle;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 11 Jan 2010 14:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Where-with-IN-freezes-SAS/m-p/38405#M9845</guid>
      <dc:creator>Bill</dc:creator>
      <dc:date>2010-01-11T14:46:22Z</dc:date>
    </item>
  </channel>
</rss>

