<?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: Update a column in a table with values from another table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540349#M149041</link>
    <description>&lt;P&gt;What do you mean by "&lt;SPAN&gt;COLUMN_NAME is an attribute on TARGET table"?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also, can you provide some sample data for us to work with, that resembles your actual data? Makes it much easier to help you.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2019 07:40:32 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-03-05T07:40:32Z</dc:date>
    <item>
      <title>Update a column in a table with values from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540348#M149040</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As part of my programming, I have a query which updates a TARGET table with values from the SOURCE table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
update SCHEMA.TARGET as u
set &amp;amp;COLUMN_NAME. =(select value from &amp;amp;COLUMN_NAME. as n
where strip(u.ID)=strip(n.ID))&lt;BR /&gt;;quit;&lt;/PRE&gt;&lt;P&gt;COLUMN_NAME is an attribute on TARGET table, it is a table as well. I am trying to update the column with values from the corresponding table. The variable values will be changed dynamically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please advise how to achieve this using data steps, this approach seems to be a bit slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 07:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540348#M149040</guid>
      <dc:creator>Sudhan</dc:creator>
      <dc:date>2019-03-05T07:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Update a column in a table with values from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540349#M149041</link>
      <description>&lt;P&gt;What do you mean by "&lt;SPAN&gt;COLUMN_NAME is an attribute on TARGET table"?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also, can you provide some sample data for us to work with, that resembles your actual data? Makes it much easier to help you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 07:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540349#M149041</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-05T07:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Update a column in a table with values from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540364#M149046</link>
      <description>&lt;P&gt;Post test data of both datasets in the form of a datastep:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And show what you expect from them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am pretty certain however that there is a much better method than the update you present here, a simple merge on ID would be far more efficient.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 08:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540364#M149046</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-05T08:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Update a column in a table with values from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540367#M149047</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=&amp;amp;column_name.;
by id;
run;

proc sort data=schema.target;
by id;
run;

data schema.target_new;
merge
  schema.target (in=orig)
  &amp;amp;column_name. (in=update keep=id value)
;
by id;
if orig;
if update then &amp;amp;column_name. = value;
drop value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have verified the result, remove schema.target and rename schema.target_new to schema.target.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 08:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-a-table-with-values-from-another-table/m-p/540367#M149047</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-05T08:36:41Z</dc:date>
    </item>
  </channel>
</rss>

