<?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 update in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251920#M56773</link>
    <description>&lt;P&gt;Are you sure that the column &lt;STRONG&gt;txn&lt;/STRONG&gt; exists in &lt;STRONG&gt;table1&lt;/STRONG&gt; and &lt;STRONG&gt;table2&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, what you trying to do exactly?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2016 23:57:26 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2016-02-23T23:57:26Z</dc:date>
    <item>
      <title>Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251910#M56770</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to update a table in proc sql, to set our columns = to a temporary work tables values.&lt;/P&gt;&lt;P&gt;The below code is not working and giving me this error:&lt;/P&gt;&lt;P&gt;ERROR: Unresolved reference to table/correlation name transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;update table1&lt;/P&gt;&lt;P&gt;set&amp;nbsp;col1 = (select&amp;nbsp;col1 from table2 where table1.txn = txn)&lt;/P&gt;&lt;P&gt;where&amp;nbsp;txn in (select txn from table2);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to avoid a datastep update statement, as it is recreating our table and seems to be a long time for a job that should be very simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 23:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251910#M56770</guid>
      <dc:creator>Bjs09f</dc:creator>
      <dc:date>2016-02-23T23:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251920#M56773</link>
      <description>&lt;P&gt;Are you sure that the column &lt;STRONG&gt;txn&lt;/STRONG&gt; exists in &lt;STRONG&gt;table1&lt;/STRONG&gt; and &lt;STRONG&gt;table2&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, what you trying to do exactly?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 23:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251920#M56773</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-23T23:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251997#M56788</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, firstly, I am not sure that an update statement like that would be quicker than a datastep. &amp;nbsp;Your datastep could be taking a long time for a number of reasons - where is it located network/locally, how many observations/columns etc.&lt;/P&gt;
&lt;P&gt;For your update, have you tried putting the Alias in the step:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  update table1 table1  /* Second one here is the alias */
  set col1 = (select col1 from table2 where table1.txn = txn)
  where txn in (select txn from table2);
quit;&lt;/PRE&gt;
&lt;P&gt;However I am not sure your logic is right at all. &amp;nbsp;The where clause will select multiple rows if they exist. &amp;nbsp;Post example test data, and what you want the output to look like and we can suggest code.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 09:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/251997#M56788</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-24T09:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252014#M56789</link>
      <description>May I that in many cases SQL is quite inefficient when it comes to updates.&lt;BR /&gt;On an indexed data set, a data step with modify by can be very fast - it does not recreate the data set, it updates it in place.</description>
      <pubDate>Wed, 24 Feb 2016 12:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252014#M56789</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-24T12:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252036#M56790</link>
      <description>&lt;P&gt;Thanks for reply,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our current code is in a datastep. The table is indexed, and it does not maintain indexes if we perform like we do below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data table1;&lt;/P&gt;&lt;P&gt;update table1&lt;/P&gt;&lt;P&gt;table2&lt;/P&gt;&lt;P&gt;UPDATEMODE=NOMISSINGCHECK;&lt;/P&gt;&lt;P&gt;by transaction_id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we are updating 2 columns on table1, which are both on table2. This step is recreating the table each time and it seems like an inefficient way to update a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 14:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252036#M56790</guid>
      <dc:creator>Bjs09f</dc:creator>
      <dc:date>2016-02-24T14:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252037#M56791</link>
      <description>&lt;P&gt;Here's some sample data of the two columns that should be updating, also the column they are updating by:txn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1 (Table to update)&lt;/P&gt;&lt;P&gt;txn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flag&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&lt;/P&gt;&lt;P&gt;1021912&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12/02/2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2(updating table one data with flag and date) flag is empty&lt;/P&gt;&lt;P&gt;txn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flag&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&lt;/P&gt;&lt;P&gt;1021912&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2/24/2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Txn is a unique index on both tables.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 14:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252037#M56791</guid>
      <dc:creator>Bjs09f</dc:creator>
      <dc:date>2016-02-24T14:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql update</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252119#M56796</link>
      <description>As stated, modify by will update in place which includes maintaining indexes.</description>
      <pubDate>Wed, 24 Feb 2016 18:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-update/m-p/252119#M56796</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-24T18:11:21Z</dc:date>
    </item>
  </channel>
</rss>

