<?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 Proc Sql Update Optimization in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49343#M13379</link>
    <description>Hello to everyone&lt;BR /&gt;
I have an optimization question about the following query&lt;BR /&gt;
&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
update Addr a &lt;BR /&gt;
set A_ID =&lt;BR /&gt;
(&lt;BR /&gt;
select ID &lt;BR /&gt;
from U_Addr&lt;BR /&gt;
where US=upcase(a.OS)&lt;BR /&gt;
and UC=upcase(a.OC)&lt;BR /&gt;
and US=upcase(a.OS)&lt;BR /&gt;
) ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
&lt;BR /&gt;
This update takes a very long time to update the Addr table.  The Addr table has 230,000 rows and the U_Addr has 67,000 rows.  The joining field are character fields which I think is one of the reason it takes so long. &lt;BR /&gt;
If anyone has an tips or comments on how to optimize this query and make it faster I would appreciate it greatly.&lt;BR /&gt;
&lt;BR /&gt;
Thank You</description>
    <pubDate>Fri, 26 Jun 2009 15:07:41 GMT</pubDate>
    <dc:creator>jerry898969</dc:creator>
    <dc:date>2009-06-26T15:07:41Z</dc:date>
    <item>
      <title>Proc Sql Update Optimization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49343#M13379</link>
      <description>Hello to everyone&lt;BR /&gt;
I have an optimization question about the following query&lt;BR /&gt;
&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
update Addr a &lt;BR /&gt;
set A_ID =&lt;BR /&gt;
(&lt;BR /&gt;
select ID &lt;BR /&gt;
from U_Addr&lt;BR /&gt;
where US=upcase(a.OS)&lt;BR /&gt;
and UC=upcase(a.OC)&lt;BR /&gt;
and US=upcase(a.OS)&lt;BR /&gt;
) ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
&lt;BR /&gt;
This update takes a very long time to update the Addr table.  The Addr table has 230,000 rows and the U_Addr has 67,000 rows.  The joining field are character fields which I think is one of the reason it takes so long. &lt;BR /&gt;
If anyone has an tips or comments on how to optimize this query and make it faster I would appreciate it greatly.&lt;BR /&gt;
&lt;BR /&gt;
Thank You</description>
      <pubDate>Fri, 26 Jun 2009 15:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49343#M13379</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2009-06-26T15:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Update Optimization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49344#M13380</link>
      <description>It would help to explain more about the SAS operating environment, particularly about the SAS code execution that leads up to the PROC SQL you have posted.  Is SAS executing against local data or through a remote connection; is a DBMS (external table) involved?  Is there variability with processing, depending on the row/observation count (try using OPTIONS OBS=nnn; for testing various scenarios).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 27 Jun 2009 16:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49344#M13380</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-27T16:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Update Optimization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49345#M13381</link>
      <description>What goes on is that for each row in Addr, you do separate look-up in U_addr.&lt;BR /&gt;
Indexing on some of the "join" columns might help.&lt;BR /&gt;
In this particular case, you will probably find it much more efficient to do a regular left join to do this update, or data step techniques.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Mon, 29 Jun 2009 07:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49345#M13381</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-06-29T07:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Update Optimization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49346#M13382</link>
      <description>Thanks guys for the replies.&lt;BR /&gt;
Everything with this query runs locally.  What i'm doing is taking a distinct list of address.  I'm adding an ID column to this distinct list then I want to go back and update each row with it's corresponding ID.&lt;BR /&gt;
&lt;BR /&gt;
With a regular left join how would I do the update part of it?&lt;BR /&gt;
&lt;BR /&gt;
Thanks again for your help&lt;BR /&gt;
Jerry</description>
      <pubDate>Mon, 29 Jun 2009 13:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49346#M13382</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2009-06-29T13:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Update Optimization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49347#M13383</link>
      <description>Since your master table seems quite small, you just can overwrite it with the query result:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table Addr as&lt;BR /&gt;
select a.*, u.A_ID&lt;BR /&gt;
from Addr as a left join U_Addr as u&lt;BR /&gt;
on u.US=upcase(a.OS)&lt;BR /&gt;
and u.UC=upcase(a.OC)&lt;BR /&gt;
and u.US=upcase(a.OS)&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Remember if you try to use indexed strategies, avoid having function calls in WHERE/ON-clauses.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Mon, 29 Jun 2009 15:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49347#M13383</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-06-29T15:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Update Optimization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49348#M13384</link>
      <description>Linus H,&lt;BR /&gt;
Thank you for your help&lt;BR /&gt;
&lt;BR /&gt;
That last sentence about the functions in the where clause opened my eyes.  I did the upcase for these  tables when I created them so I didn't have to do it in the join.  The time when from 24 minutes to under 3.&lt;BR /&gt;
&lt;BR /&gt;
Thank you so much&lt;BR /&gt;
&lt;BR /&gt;
Jerry</description>
      <pubDate>Mon, 29 Jun 2009 15:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Update-Optimization/m-p/49348#M13384</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2009-06-29T15:51:25Z</dc:date>
    </item>
  </channel>
</rss>

