<?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: proc SQL update table with CASE when in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308114#M270653</link>
    <description>&lt;PRE&gt;
data have;
 length sex $ 20;
 sex='M';age=12;output;
 sex='F';age=1;output;
run;
proc sql;
update have as a
set sex=
 case 
 when (exists(select * from sashelp.class where age=a.age))
  then 'TRUE'
 else 'FALUSE' 
 end;
quit;


&lt;/PRE&gt;</description>
    <pubDate>Sun, 30 Oct 2016 03:33:51 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-10-30T03:33:51Z</dc:date>
    <item>
      <title>proc SQL update table with CASE when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308107#M270652</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help with writing this SQL correctly. I need to update/alter a table with status of 'SUCCESS/FAILURE' &amp;nbsp;based on the case condition .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE &amp;amp;SUM_TABLE A&lt;BR /&gt;SET&lt;BR /&gt;STAT = 'SUCCESS' &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case WHEN ((B.INPUT_CNT - A.UNIQUE_CLAIM_ID)=0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(SELECT COUNT(*) AS INPUT_CNT&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FROM MANUAL_TEMP B)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;ELSE 'FAILURE'&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Sun, 30 Oct 2016 01:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308107#M270652</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-10-30T01:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc SQL update table with CASE when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308114#M270653</link>
      <description>&lt;PRE&gt;
data have;
 length sex $ 20;
 sex='M';age=12;output;
 sex='F';age=1;output;
run;
proc sql;
update have as a
set sex=
 case 
 when (exists(select * from sashelp.class where age=a.age))
  then 'TRUE'
 else 'FALUSE' 
 end;
quit;


&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Oct 2016 03:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308114#M270653</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-30T03:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc SQL update table with CASE when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308116#M270654</link>
      <description>&lt;P&gt;Proper syntax would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;UPDATE &amp;amp;SUM_TABLE
SET
	STAT = case 
		when UNIQUE_CLAIM_ID = (SELECT COUNT(*) FROM MANUAL_TEMP)
			then 'SUCCESS'
			else 'FAILURE'
			end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I doubt that this is what you really want to do. I doesn't look right to equate a claim ID with the record count in another table. Could you explain what the SUCCESS/FAILURE condition is supposed to be?&lt;/P&gt;</description>
      <pubDate>Sun, 30 Oct 2016 04:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-SQL-update-table-with-CASE-when/m-p/308116#M270654</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-30T04:10:28Z</dc:date>
    </item>
  </channel>
</rss>

