<?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 Multiple values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Update-Multiple-values/m-p/572837#M75356</link>
    <description>&lt;P&gt;I have a table created in SAS with a list of values. I have a secondary table that I caluclated values on based on table 1.&lt;/P&gt;&lt;P&gt;I am wanting to update table 1 with the calculated values from table 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;update TEST_MAIN&amp;nbsp;&lt;BR /&gt;set (value_1) = (select calc1 from CR_CALC)&lt;BR /&gt;where FIELD= 'CR';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This updated the VALUE_1 field with the data i need.&lt;/P&gt;&lt;P&gt;however, I have multiple fields to update so I used this example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;update TEST_MAIN&amp;nbsp;&lt;BR /&gt;set (value_1, value2) = (select calc1. calc2 from CR_CALC)&lt;BR /&gt;where FIELD= 'CR';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure what the error is. I used this in SQL syntax all the time without issue.&lt;/P&gt;&lt;P&gt;Thank You!&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2019 16:48:34 GMT</pubDate>
    <dc:creator>crashz204</dc:creator>
    <dc:date>2019-07-11T16:48:34Z</dc:date>
    <item>
      <title>Proc SQL Update Multiple values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Update-Multiple-values/m-p/572837#M75356</link>
      <description>&lt;P&gt;I have a table created in SAS with a list of values. I have a secondary table that I caluclated values on based on table 1.&lt;/P&gt;&lt;P&gt;I am wanting to update table 1 with the calculated values from table 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;update TEST_MAIN&amp;nbsp;&lt;BR /&gt;set (value_1) = (select calc1 from CR_CALC)&lt;BR /&gt;where FIELD= 'CR';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This updated the VALUE_1 field with the data i need.&lt;/P&gt;&lt;P&gt;however, I have multiple fields to update so I used this example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;update TEST_MAIN&amp;nbsp;&lt;BR /&gt;set (value_1, value2) = (select calc1. calc2 from CR_CALC)&lt;BR /&gt;where FIELD= 'CR';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure what the error is. I used this in SQL syntax all the time without issue.&lt;/P&gt;&lt;P&gt;Thank You!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 16:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Update-Multiple-values/m-p/572837#M75356</guid>
      <dc:creator>crashz204</dc:creator>
      <dc:date>2019-07-11T16:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Update Multiple values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Update-Multiple-values/m-p/572842#M75358</link>
      <description>&lt;P&gt;Not sure what flavor of SQL you are used to using but that syntax is not supported in the SQL standard that PROC SQL uses.&lt;/P&gt;
&lt;P&gt;Check out the documentation:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=sqlproc&amp;amp;docsetTarget=p0ci36zwxhm1xdn1a943yeczfalk.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=sqlproc&amp;amp;docsetTarget=p0ci36zwxhm1xdn1a943yeczfalk.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
update TEST_MAIN 
set var_1= (select calc1 from CR_CALC)
  , var_2 = (select calc2 from CR_CALC)
where FIELD= 'CR'
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure that the subqueries return one and only one value.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 16:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Update-Multiple-values/m-p/572842#M75358</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-11T16:54:18Z</dc:date>
    </item>
  </channel>
</rss>

