<?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 Values returned from a join only in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184602#M46947</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SQL doesn't really acknowledge order, so unless you have a way to identify the "first" record I'm not sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could take the max or min if you don't actually care about order. The key is to get a query that returns only one value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'd also need quotes around October, I'm assuming it's simply a typo here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Proc Sql;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;update Test&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Set Product = (select max(b.product) from&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Table1 (where = (type = 1 and month = "October"))&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;inner join Table2 on&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;a.criteria1 = b.criteria1 and&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;a.criteria2 = b.criteria2&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;)&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Nov 2014 08:46:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-11-25T08:46:55Z</dc:date>
    <item>
      <title>Updating Values returned from a join only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184598#M46943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to run the following piece of code. Basically, I am trying to update the selected values from the where statement with the internal_product value returned from the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I am getting the error Subquery evaluated to more than one row. I should probably add that each product is linked to an account number in another column. Do I have to do some sort of grouping?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering if anyone could help restructure my code, or explain what is going on that is incorrect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Sql;&lt;/P&gt;&lt;P&gt;update Test&lt;/P&gt;&lt;P&gt;Set Product = (select b.product from&lt;/P&gt;&lt;P&gt;Table1 (where = (type = 1 and month = October))&lt;/P&gt;&lt;P&gt;inner join Table2 on&lt;/P&gt;&lt;P&gt;a.criteria1 = b.criteria1 and&lt;/P&gt;&lt;P&gt;a.criteria2 = b.criteria2&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 19:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184598#M46943</guid>
      <dc:creator>micksom</dc:creator>
      <dc:date>2014-11-24T19:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Values returned from a join only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184599#M46944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do any SAS gurus know if such a feat is possible in proc sql?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 07:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184599#M46944</guid>
      <dc:creator>micksom</dc:creator>
      <dc:date>2014-11-25T07:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Values returned from a join only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184600#M46945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;micksom wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I should probably add that each product is linked to an account number in another column. &lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you tried joining on account number as well?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 07:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184600#M46945</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-25T07:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Values returned from a join only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184601#M46946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don;t actually want to join on account number. The account number in table2 is different and not really linked to table1. I just really want to return the first value it finds based on criteria1 and criteria2. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 07:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184601#M46946</guid>
      <dc:creator>micksom</dc:creator>
      <dc:date>2014-11-25T07:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Values returned from a join only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184602#M46947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SQL doesn't really acknowledge order, so unless you have a way to identify the "first" record I'm not sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could take the max or min if you don't actually care about order. The key is to get a query that returns only one value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'd also need quotes around October, I'm assuming it's simply a typo here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Proc Sql;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;update Test&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Set Product = (select max(b.product) from&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Table1 (where = (type = 1 and month = "October"))&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;inner join Table2 on&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;a.criteria1 = b.criteria1 and&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;a.criteria2 = b.criteria2&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;)&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 08:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184602#M46947</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-25T08:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Values returned from a join only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184603#M46948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you post a bit of test data for each table, and what you expect out of it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 09:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Updating-Values-returned-from-a-join-only/m-p/184603#M46948</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-25T09:36:49Z</dc:date>
    </item>
  </channel>
</rss>

