<?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: Updating column of one table with another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594783#M170968</link>
    <description>Well, what happens when multiple rows meet the condition? Is there a date field you need to be using to limit it? Why do you have duplicates?</description>
    <pubDate>Tue, 08 Oct 2019 15:25:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-10-08T15:25:14Z</dc:date>
    <item>
      <title>Updating column of one table with another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594777#M170964</link>
      <description>&lt;P&gt;good morning,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either sql or data step is fine with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to update the obligating_doc_no rom pips_data with obligating_document_no from B7600 table. I get an error indicating that "&lt;/P&gt;&lt;P&gt;ERROR: Subquery evaluated to more than one row.&lt;/P&gt;&lt;P&gt;NOTE: Correlation values are: IPAC='89000001' ." I used the code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;update&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pips_data p&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; obligating_doc_no =&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(select obligating_doc_no&lt;/P&gt;&lt;P&gt;from tableB b&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; p.ipac = b.ipac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; obligating_doc_no in&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(select obligating_doc_no&lt;/P&gt;&lt;P&gt;from tableB&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 15:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594777#M170964</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2019-10-08T15:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Updating column of one table with another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594783#M170968</link>
      <description>Well, what happens when multiple rows meet the condition? Is there a date field you need to be using to limit it? Why do you have duplicates?</description>
      <pubDate>Tue, 08 Oct 2019 15:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594783#M170968</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-08T15:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Updating column of one table with another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594831#M171001</link>
      <description>&lt;P&gt;That is how the data is. No date.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 17:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594831#M171001</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2019-10-08T17:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Updating column of one table with another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594832#M171002</link>
      <description>I cannot download attachments so have no idea about your data unless you include it directly in the post. Regardless, the SAS error is telling you have duplicates returned. In that situation, which value do you want to use? You need to make a, usually, business/subject matter expertise decision to determine which record is required. If you have exact duplicates for some reason, you can either first remove duplicates or you can use MAX()/MIN() on the character variables.</description>
      <pubDate>Tue, 08 Oct 2019 17:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594832#M171002</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-08T17:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Updating column of one table with another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594882#M171029</link>
      <description>&lt;P&gt;It is pretty easy to see that you have duplicate values for OBLIGATING_DOC_NO with the same IPAC value. This is from the first 3 data lines of your B7600s.csv, which I have to &lt;STRONG&gt;assume&lt;/STRONG&gt; is related to your TableB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;IPAC	OBLIGATING_DOC_NO	TAS	ACCOUNTING
89000001	89233119SNA000165	08920192020 0251000	01278.2019.01.100260.2510
89000001	89233119SNA000165	089 X0251000	01250.2019.01.100260.2510
89000001	89233119SNA000165	08920192020 0240000	70052.2019.60.300602.2510
&lt;/PRE&gt;
&lt;P&gt;Subqueries used like the highlighted need to return a single value&lt;/P&gt;
&lt;PRE&gt;proc sql;
update pips_data p

set obligating_doc_no &lt;STRONG&gt;&lt;FONT color="#008000"&gt;=
(select obligating_doc_no
from tableB b
where p.ipac = b.ipac
)
&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;like the error message says. So you need an additional filter on your data to ensure you get one and only one value of the variable from the subquery for the value of Ipac.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 19:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-column-of-one-table-with-another/m-p/594882#M171029</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-08T19:33:37Z</dc:date>
    </item>
  </channel>
</rss>

