<?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 Case When in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142109#M261653</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try modifying case statement syntax in above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case&lt;/P&gt;&lt;P&gt;when&amp;nbsp; remaining_months &amp;lt;= 1 then 'End'&lt;/P&gt;&lt;P&gt;when Remaining_months &amp;lt;= 12 then 'End OP'&lt;/P&gt;&lt;P&gt;when arrs ne '1' then 'Ars'&lt;/P&gt;&lt;P&gt;else 'Rege' end as Red_son&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Jul 2014 14:32:24 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-07-30T14:32:24Z</dc:date>
    <item>
      <title>Proc SQL Case When</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142108#M261652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some code that runs fine but when i add in the case statement on Proc SQL it 'falls over'. Can anyone please advise where I am going wrong with the complete statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;create table work.red as&lt;BR /&gt;select &lt;BR /&gt;num,&lt;BR /&gt;month_date,&lt;BR /&gt;arrs,&lt;BR /&gt;remaining_months,&amp;nbsp; &lt;BR /&gt;platform,&lt;BR /&gt;valuation,&lt;BR /&gt;Type,&lt;/P&gt;&lt;P&gt;count(*) as count,&lt;BR /&gt;avg (tv) ,&lt;BR /&gt;avg (bal),&lt;/P&gt;&lt;P&gt;case when&amp;nbsp; &lt;BR /&gt;remaining_months &amp;lt;= 1 then 'End'&lt;BR /&gt;else if Remaining_months &amp;lt;= 12 then 'End OP'&lt;BR /&gt;else if arrs not in '1' then 'Ars' else 'Rege' end as Red_son&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from &lt;BR /&gt;sun.sunny&lt;/P&gt;&lt;P&gt;where &lt;BR /&gt;platform = 'O'&lt;BR /&gt;and Arrs not in ('L4','L5','L6')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;group by &lt;/P&gt;&lt;P&gt;num,&lt;/P&gt;&lt;P&gt;month_date&lt;/P&gt;&lt;P&gt;arrs&lt;/P&gt;&lt;P&gt;remaining_months&amp;nbsp; &lt;/P&gt;&lt;P&gt;platform&lt;/P&gt;&lt;P&gt;valuation&lt;/P&gt;&lt;P&gt;Type&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 14:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142108#M261652</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2014-07-30T14:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case When</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142109#M261653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try modifying case statement syntax in above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case&lt;/P&gt;&lt;P&gt;when&amp;nbsp; remaining_months &amp;lt;= 1 then 'End'&lt;/P&gt;&lt;P&gt;when Remaining_months &amp;lt;= 12 then 'End OP'&lt;/P&gt;&lt;P&gt;when arrs ne '1' then 'Ars'&lt;/P&gt;&lt;P&gt;else 'Rege' end as Red_son&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 14:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142109#M261653</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-30T14:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Case When</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142110#M261654</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;you are mixing SAS syntax and SQL there:&lt;/P&gt;&lt;P&gt;case&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remaining_months &amp;lt;= 1 then 'End'&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; when&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remaining_months &amp;lt;= 12 then 'End OP'&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; when&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrs not in '1' then 'Ars'&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; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Rege' end as Red_son&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax is:&lt;/P&gt;&lt;P&gt;case&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when&amp;nbsp; [condition] then [result]&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; else [fallout response] end&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 14:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Case-When/m-p/142110#M261654</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-30T14:34:27Z</dc:date>
    </item>
  </channel>
</rss>

