<?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: How to update values with multiple columns by using PROC SQL? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332786#M62791</link>
    <description>&lt;P&gt;The case expression must supply every possibility. In the absence of an else clause, cases that are not covered result in a missing value. So, replace&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;marital=case when marital in (2, 4) then 2 end&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;with&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;marital=case when marital in (2, 4) then 2 else marital end&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and so on.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 20:39:27 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-02-14T20:39:27Z</dc:date>
    <item>
      <title>How to update values with multiple columns by using PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332768#M62788</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning using PROC SQL to replace the data step for data extraction. &amp;nbsp; &amp;nbsp;I use PROC SQL / UPDATE statement, I found that I didn't update my data correctly, I lost some portion of my original&amp;nbsp;ones.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;update work, test&amp;nbsp;&lt;BR /&gt;set&lt;BR /&gt;marital=case when marital in (2, 4) then 2 end,&lt;BR /&gt;race=case when race in (3,5,6,7,8) then 7&lt;BR /&gt;when race in (4) then 9 end;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As showing above, I got "martial 2 and 4" changing to 2, but missing 1 and 3 original categories&amp;nbsp;in the updated data. &amp;nbsp;The same as race, I only got the 7 and 9 in race columns, but missing 1 and 2 original rows in the updated table. &amp;nbsp; How to avoid&amp;nbsp;this problem? &amp;nbsp;Please advice. &amp;nbsp;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 19:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332768#M62788</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-02-14T19:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to update values with multiple columns by using PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332785#M62790</link>
      <description>&lt;P&gt;Your case statements logic is incorrect,&amp;nbsp;ALWAYS read your log. You should see the following NOTE and if you read the last sentence it explains your situation. Add the ELSE clause so that the value stays the same if you don't change it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;397&lt;BR /&gt;398 proc sql;&lt;BR /&gt;399 update class&lt;BR /&gt;400 set age=case when age &amp;lt; 10 then 5 end;&lt;BR /&gt;&lt;U&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;NOTE: A CASE expression has no ELSE clause. Cases not accounted for by the WHEN clauses will&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;&lt;U&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt; result in a missing value for the CASE expression.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;NOTE: 19 rows were updated in WORK.CLASS.&lt;/P&gt;
&lt;P&gt;401 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; real time 0.06 seconds&lt;BR /&gt; cpu time 0.01 seconds&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 20:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332785#M62790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-14T20:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to update values with multiple columns by using PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332786#M62791</link>
      <description>&lt;P&gt;The case expression must supply every possibility. In the absence of an else clause, cases that are not covered result in a missing value. So, replace&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;marital=case when marital in (2, 4) then 2 end&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;with&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;marital=case when marital in (2, 4) then 2 else marital end&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and so on.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 20:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-update-values-with-multiple-columns-by-using-PROC-SQL/m-p/332786#M62791</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-02-14T20:39:27Z</dc:date>
    </item>
  </channel>
</rss>

