<?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: Missing ELSE statement? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955817#M45699</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;I suspect you could do something much simpler than this. I think it would be helpful if you first wrote out what you want in plain English (i.e., not code) - better yet, draw it (like a tree diagram).&amp;nbsp; &amp;nbsp;I have literally never seen that degree of nesting / daisy-chaining with CASE statements.&amp;nbsp;&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>Sat, 11 Jan 2025 21:37:26 GMT</pubDate>
    <dc:creator>quickbluefish</dc:creator>
    <dc:date>2025-01-11T21:37:26Z</dc:date>
    <item>
      <title>Missing ELSE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955816#M45698</link>
      <description>&lt;P&gt;I'm doing a case when but I'm getting a NOTE that Case has no ELSE clause.&amp;nbsp; Should I be using "AND" instead of "THEN" in certain places? Do I have too many END statements?&amp;nbsp; Any help is appreciated.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;92    proc sql;
93         create table work.short2 as
94            select a.*,
95    case when missing(a.date)then .
96         when a.date&amp;lt;="05may2024"d then
97              case when a.m_score &amp;gt;= 0.13 then 1 else 0 end
98    else case when a.date &amp;gt;="06may2024"d then case when
99    a.Days &amp;gt;= 20 then 1 else 0 end
100   end
101   end as T_Flag
102              from short a
103                 left join b.rti b
104                    on a.id= b.id and
105                       a.sflag = b.sflag;
NOTE: A CASE expression has no ELSE clause. Cases not accounted for by the WHEN clauses will result in a missing value for the CASE 
      expression.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Jan 2025 20:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955816#M45698</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2025-01-11T20:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Missing ELSE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955817#M45699</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;I suspect you could do something much simpler than this. I think it would be helpful if you first wrote out what you want in plain English (i.e., not code) - better yet, draw it (like a tree diagram).&amp;nbsp; &amp;nbsp;I have literally never seen that degree of nesting / daisy-chaining with CASE statements.&amp;nbsp;&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>Sat, 11 Jan 2025 21:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955817#M45699</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-11T21:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Missing ELSE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955818#M45700</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* fake data */
libname b (work);
data short b.rti(keep=id sflag);
  id = 1;
  sflag = 2;
  date = "06may2024"d;
  days = 42;
  m_score = 0.16;
run;


proc sql;
create table work.short2 as
select a.*,

case when missing(a.date) then .
     when a.date&amp;lt;="05may2024"d then
          case when a.m_score &amp;gt;= 0.13 then 1 else 0 end

     else 
          case when a.date &amp;gt;="06may2024"d then 
               case when a.Days &amp;gt;= 20 then 1 
                                      else 0 
               end
                                          ELSE .  /* missing ELSE */
          end
end 
as T_Flag

from short a
  left join 
     b.rti b
  on a.id = b.id 
  and a.sflag = b.sflag
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Jan 2025 21:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955818#M45700</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-01-11T21:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Missing ELSE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955819#M45701</link>
      <description>&lt;P&gt;I don't think nesting CASE expressions is what you intended as it doesn't make a lot of sense. Maybe something more like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   case 
      when missing(a.date) then .
      when a.date&amp;lt;="05may2024"d and a.m_score &amp;gt;= 0.13 then 1
      when a.date&amp;lt;="05may2024"d and a.m_score &amp;lt;  0.13 then 0  
      when a.date &amp;gt;="06may2024"d and a.Days &amp;gt;= 20 then 1
      when a.date &amp;gt;="06may2024"d and a.Days &amp;lt; 20 then 0 
     else 0
   end as T_Flag&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2025 21:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955819#M45701</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-01-11T21:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Missing ELSE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955841#M45702</link>
      <description>&lt;P&gt;Proper code formatting will quickly reveal where the ELSE is missing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case
  when missing(a.date)&lt;BR /&gt;  then .
  when a.date &amp;lt;= "05may2024"d
  then case
    when a.m_score &amp;gt;= 0.13
    then 1
    else 0
  end
  else case /* CASE starts here */
    when a.date &amp;gt;= "06may2024"d
    then case 
      when a.Days &amp;gt;= 20
      then 1
      else 0
    end
  end /* case ends here, but no ELSE after WHEN/THEN */
end as T_Flag
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Writing spaghetti code is always bad and makes code unmaintainable.&amp;nbsp;&lt;STRONG&gt;DO NOT DO IT.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2025 14:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955841#M45702</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-01-12T14:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Missing ELSE statement?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955862#M45704</link>
      <description>Thank you much!!!</description>
      <pubDate>Mon, 13 Jan 2025 00:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Missing-ELSE-statement/m-p/955862#M45704</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2025-01-13T00:33:55Z</dc:date>
    </item>
  </channel>
</rss>

