<?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: multiple SET in PROC SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/multiple-SET-in-PROC-SQL/m-p/229214#M54370</link>
    <description>&lt;P&gt;Unfortunately, the SQL UPDATE syntax is quite rigid. You must repeat the subquery on each assignment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update want as a 
set 
  CntA = (select coalesce(sum(A),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1)
, CntB = (select coalesce(sum(B),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1)
, CntC = (select coalesce(sum(C),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1)
, CntD = (select coalesce(sum(D),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
    <pubDate>Fri, 09 Oct 2015 02:31:29 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-10-09T02:31:29Z</dc:date>
    <item>
      <title>multiple SET in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/multiple-SET-in-PROC-SQL/m-p/229196#M54368</link>
      <description>&lt;P&gt;I am trying to update multiple columns using SQL update. It gives me error at highlighted and undelined area (at the end of the where clause)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;update want as a &lt;BR /&gt;set CntA = (select coalesce(sum(A),0)&lt;BR /&gt;, CntB&amp;nbsp;= (select coalesce(sum(B),0)&lt;BR /&gt;, CntC&amp;nbsp;= (select coalesce(sum(C),0)&lt;BR /&gt;, CntD = (select coalesce(sum(D),0)&lt;BR /&gt;from have&amp;nbsp;where (a.Originator = Originator) and (year) between (a.year)-8 and (a.failureyear)-1&lt;U&gt;&lt;FONT color="#FF00FF"&gt;;&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 22:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/multiple-SET-in-PROC-SQL/m-p/229196#M54368</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-10-08T22:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: multiple SET in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/multiple-SET-in-PROC-SQL/m-p/229214#M54370</link>
      <description>&lt;P&gt;Unfortunately, the SQL UPDATE syntax is quite rigid. You must repeat the subquery on each assignment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update want as a 
set 
  CntA = (select coalesce(sum(A),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1)
, CntB = (select coalesce(sum(B),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1)
, CntC = (select coalesce(sum(C),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1)
, CntD = (select coalesce(sum(D),0) 
	from have 
	where (a.Originator = Originator) and year between (a.year)-8 and (a.failureyear)-1);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 02:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/multiple-SET-in-PROC-SQL/m-p/229214#M54370</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-10-09T02:31:29Z</dc:date>
    </item>
  </channel>
</rss>

