<?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: Nested (multiple) when statement in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Nested-multiple-when-statement-in-proc-sql/m-p/830389#M328110</link>
    <description>&lt;P&gt;You can't compound the conditions with another WHEN ( you would need another CASE) or add an AND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	when ( length(strip(_datetime)) GE 9 ) &amp;amp; _date1 GT _date2 then 'N'
	end as var1_new
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The other END makes me wonder if this is already part of a nested case statement though, which means you may need to post the whole nest to debug it.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2022 17:41:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-08-25T17:41:29Z</dc:date>
    <item>
      <title>Nested (multiple) when statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-multiple-when-statement-in-proc-sql/m-p/830385#M328107</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a variable and assigned a character value based on the criteria.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to do this step by using the proc sql.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I am using following code, I am getting an error.&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#FF0000"&gt;______&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;22&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;76&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, '.', /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, ELSE, EQ, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;EQT, GE, GET, GT, GTT, LE, LET, LT, LTT, NE, NET, OR, WHEN, ^=, |, ||, ~=.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#FF0000"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
		create table test2 as
		select *, case 
			when ( length(strip(_datetime)) GE 9 ) then 
					when _date1 GT _date2 then 'N'
					end as var1_new
			end

from test1 ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2022 17:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-multiple-when-statement-in-proc-sql/m-p/830385#M328107</guid>
      <dc:creator>dht115</dc:creator>
      <dc:date>2022-08-25T17:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Nested (multiple) when statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-multiple-when-statement-in-proc-sql/m-p/830389#M328110</link>
      <description>&lt;P&gt;You can't compound the conditions with another WHEN ( you would need another CASE) or add an AND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	when ( length(strip(_datetime)) GE 9 ) &amp;amp; _date1 GT _date2 then 'N'
	end as var1_new
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The other END makes me wonder if this is already part of a nested case statement though, which means you may need to post the whole nest to debug it.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 17:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-multiple-when-statement-in-proc-sql/m-p/830389#M328110</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-25T17:41:29Z</dc:date>
    </item>
  </channel>
</rss>

