<?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 with left join clause so long in execution. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282517#M59186</link>
    <description>&lt;P&gt;A guess that should help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Copy the subset of lib2 to WORK and do the ID transform during the copy.&amp;nbsp; The left join may be making multiple passes through lib2 and input is not the most efficient function in SAS.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jul 2016 18:51:14 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2016-07-06T18:51:14Z</dc:date>
    <item>
      <title>Proc SQL with left join clause so long in execution.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282481#M59179</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Please i think i need help here.&lt;/P&gt;&lt;P&gt;I Have a proc sql code running for more than 4 hours to give me an output.&lt;/P&gt;&lt;P&gt;the dataset on the left (Base0) has only 1 million rows, but&amp;nbsp;Base2 is a remote dataset in a global repository.&lt;/P&gt;&lt;P&gt;PLEASE why does it takes so long to execute (4 hours) ?&lt;/P&gt;&lt;P&gt;How can it be optimized ?&lt;/P&gt;&lt;P&gt;NB Note than the key variable doesnt have the same structure in both dataset.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="4"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; lib1.Base1 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;a.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt;*, b.DW_DATE_KEY, b.SERVICE_CLASS,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;b.TOTAL_VOICE_AMT,b.TOTAL_DURATION,&lt;/P&gt;&lt;P&gt;b.NB_CALLS, b.NB_CALLS_ONNET, b.NB_CALLS_OFFNET,b.NB_CALLS_INTERNATIONAL,&lt;/P&gt;&lt;P&gt;b.VOICE_AMT_ONNET,b.VOICE_AMT_OFFNET,b.VOICE_AMT_INTERNATIONAL,&lt;/P&gt;&lt;P&gt;b.VOICE_DUREE_ONNET,b.VOICE_DUREE_OFFNET , b.VOICE_DUREE_INTERNATIONAL,&lt;/P&gt;&lt;P&gt;b.MA_VOICE_USED, b.BONUS_VOICE_USED&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; lib1.Base0 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; a&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;left&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;join&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; lib2.Base1(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; =(DW_DATE_KEY &amp;gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;20160516&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; DW_DATE_KEY &amp;lt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;20160630&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt;)) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; b&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;on&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt; a.msisdn =(input(b.msisdn, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;best12.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt;)-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;237000000000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;quit&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;FONT face="Courier New" size="4"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2016 16:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282481#M59179</guid>
      <dc:creator>KOUPGANG</dc:creator>
      <dc:date>2016-07-06T16:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with left join clause so long in execution.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282517#M59186</link>
      <description>&lt;P&gt;A guess that should help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Copy the subset of lib2 to WORK and do the ID transform during the copy.&amp;nbsp; The left join may be making multiple passes through lib2 and input is not the most efficient function in SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2016 18:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282517#M59186</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2016-07-06T18:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with left join clause so long in execution.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282518#M59187</link>
      <description>&lt;P&gt;I'd fetch the base2 table to a local SAS dataset in a separate step. In that step, do the calculation for your key. Then sort per the key, which should make things much easier for the SQL step.&lt;/P&gt;
&lt;P&gt;You might still find that proc sort and a data step merge are faster. If you have a many-to many relationship requiring a cartesian join, you must use SQL, of course.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2016 18:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282518#M59187</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-06T18:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with left join clause so long in execution.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282637#M59196</link>
      <description>Thanks a lot. Its faster whith Base2 dataset in Work library.&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Jul 2016 08:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282637#M59196</guid>
      <dc:creator>KOUPGANG</dc:creator>
      <dc:date>2016-07-07T08:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with left join clause so long in execution.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282638#M59197</link>
      <description>Options msglevel = i sastrace = ',,,d' sastraceloc = saslog;&lt;BR /&gt;Helps you understand what gets passed to the underlying dbms.&lt;BR /&gt;Try to avoid function calls in filter/join criterias. &lt;BR /&gt;How many records does base2 have?&lt;BR /&gt;How many records typically meet the date fire criteria? &lt;BR /&gt;Any indexes on dw_date_key or msisdn?</description>
      <pubDate>Thu, 07 Jul 2016 08:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-with-left-join-clause-so-long-in-execution/m-p/282638#M59197</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-07T08:43:46Z</dc:date>
    </item>
  </channel>
</rss>

