<?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: ERROR 22-322: Syntax error with case statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469596#M30457</link>
    <description>&lt;P&gt;I think that&lt;/P&gt;
&lt;P&gt;end CUST_TYPE_CD,&lt;/P&gt;
&lt;P&gt;(having a label after the end statement) isn't valid in SAS (untested).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jun 2018 12:33:16 GMT</pubDate>
    <dc:creator>TomKari</dc:creator>
    <dc:date>2018-06-12T12:33:16Z</dc:date>
    <item>
      <title>ERROR 22-322: Syntax error with case statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469421#M30444</link>
      <description>&lt;P&gt;Hello. I'm trying to figure out why I'm getting this error, which seems to be connected to the case/when statement but it runs fine in Toad.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&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, AS, CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select i.CUSTOMER_ACCOUNT_KEY,i.SITE_ID, i.SITE_DESC, i.CUSTOMER_KEY, i.ACCOUNT_NUMBER, i.CUSTOMER_NAME, i.HOME_AREA_CODE, i.HOME_PHONE_NUMBER,i.CUSTOMER_STATUS_CODE,&lt;BR /&gt;case&lt;BR /&gt;when a.CUSTOMER_CATEGORY_CODE = 'T'&lt;BR /&gt;then 'Test'&lt;BR /&gt;else 'Customer'&lt;BR /&gt;end CUST_CAT_CODE,&lt;/P&gt;&lt;P&gt;case CUSTOMER_TYPE_CODE&lt;BR /&gt;when 'V'&lt;BR /&gt;then 'Employee'&lt;BR /&gt;when '4'&lt;BR /&gt;then 'Memo'&lt;BR /&gt;when '5'&lt;BR /&gt;then 'Memo'&lt;BR /&gt;when 'I'&lt;BR /&gt;then 'Internal'&lt;BR /&gt;else 'Default'&lt;BR /&gt;end CUST_TYPE_CD,&lt;/P&gt;&lt;P&gt;e.EQUIPMENT_STATUS_DESC, e.ITEM_NBR, e.ITEM_DESC, e.ICOMS_SERIAL_NBR, e.START_DT_KEY, e.END_DT_KEY,&lt;BR /&gt;case END_DT_KEY&lt;BR /&gt;when 99991231&lt;BR /&gt;then 'N'&lt;BR /&gt;else 'Y'&lt;BR /&gt;end SWAP_STATUS&lt;BR /&gt;from CM.ALL_INDIVIDUALS i&lt;BR /&gt;join CM.ALL_ACCOUNTS a on i.CUSTOMER_ACCOUNT_KEY = a.CUSTOMER_ACCOUNT_KEY&lt;BR /&gt;join CM.ALL_CUST_EQUIPMENT e on i.CUSTOMER_ACCOUNT_KEY = e.CUSTOMER_ACCOUNT_KEY&lt;BR /&gt;where ITEM_NBR in ('MPX032','CPX032') AND&lt;BR /&gt;e.END_DT_KEY &amp;gt; 20180401 AND&lt;BR /&gt;--CUSTOMER_TYPE_CODE = '%Default%' and&lt;BR /&gt;--i.SITE_ID in (1, 334, 541, 333, 334 ) AND&lt;BR /&gt;--e.EQUIPMENT_STATUS_DESC = 'INSTALLED AT CUSTOMER'&lt;BR /&gt;i.CUSTOMER_ACCOUNT_KEY IN('1051947001',&lt;BR /&gt;'1008410505')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;order by end_dt_key DESC&lt;BR /&gt;--and a.CUSTOMER_CATEGORY_CODE = 'Customer'&lt;BR /&gt;--AND e.END_DT_KEY = 99991231;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;26 case&lt;/P&gt;&lt;P&gt;27 when a.CUSTOMER_CATEGORY_CODE = 'T'&lt;/P&gt;&lt;P&gt;28 then 'Test'&lt;/P&gt;&lt;P&gt;29 else 'Customer'&lt;/P&gt;&lt;P&gt;30 end CUST_CAT_CODE,&lt;/P&gt;&lt;P&gt;_____________&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&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, AS,&lt;/P&gt;&lt;P&gt;CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;&lt;P&gt;31&lt;/P&gt;&lt;P&gt;32 case CUSTOMER_TYPE_CODE&lt;/P&gt;&lt;P&gt;33 when 'V'&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT, FULL, GROUP, HAVING, INNER, INTERSECT,&lt;/P&gt;&lt;P&gt;JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.&lt;/P&gt;&lt;P&gt;34 then 'Employee'&lt;/P&gt;&lt;P&gt;35 when '4'&lt;/P&gt;&lt;P&gt;33 when 'V'&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 21:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469421#M30444</guid>
      <dc:creator>kjfswat</dc:creator>
      <dc:date>2018-06-11T21:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322: Syntax error with case statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469424#M30445</link>
      <description>&lt;P&gt;If you don't post the log messages using the {i} icon to open a pop-up window then the Forum editor mangles the formatting of the message and make it almost impossible to see what SAS is complaining about.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 22:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469424#M30445</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-11T22:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322: Syntax error with case statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469425#M30446</link>
      <description>&lt;P&gt;Please post code and log entries into a code box opened using the forum's {i} icon. The code box will preserve formatting of text and in the case of error message the position of the error which is often indicated with underscore characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first error I think is that for CASE statements SAS really wants to see the AS at the end such as the "end as Region" below.&lt;/P&gt;
&lt;PRE&gt;   select Name, case
                when Continent = 'North America' then 'Continental U.S.'
                when Continent = 'Oceania' then 'Pacific Islands'
                else 'None'
                end as Region
      from states;
&lt;/PRE&gt;
&lt;P&gt;Since the first CASE statement had an error then the following error messages could be confusion due to the nature of the first error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your code actually contains -- characters in this code:&lt;/P&gt;
&lt;PRE&gt;e.END_DT_KEY &amp;gt; 20180401 AND
--CUSTOMER_TYPE_CODE = '%Default%' and
--i.SITE_ID in (1, 334, 541, 333, 334 ) AND
--e.EQUIPMENT_STATUS_DESC = 'INSTALLED AT CUSTOMER'
i.CUSTOMER_ACCOUNT_KEY IN('1051947001',
'1008410505')
&lt;/PRE&gt;
&lt;P&gt;remove them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 22:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469425#M30446</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-11T22:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322: Syntax error with case statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469427#M30447</link>
      <description>&lt;P&gt;Why do you have double minus signs in your code?&lt;/P&gt;
&lt;P&gt;If you negate a number twice it is the same as doing nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by end_dt_key DESC
--and a.CUSTOMER_CATEGORY_CODE = 'Customer'
--AND e.END_DT_KEY = 99991231;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to list more variables for your ORDER BY clause you need have commas between them.&lt;/P&gt;
&lt;P&gt;If you want to comment out code you need to use&amp;nbsp;/* ... */ comments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 22:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469427#M30447</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-11T22:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322: Syntax error with case statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469596#M30457</link>
      <description>&lt;P&gt;I think that&lt;/P&gt;
&lt;P&gt;end CUST_TYPE_CD,&lt;/P&gt;
&lt;P&gt;(having a label after the end statement) isn't valid in SAS (untested).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 12:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469596#M30457</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-06-12T12:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322: Syntax error with case statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469744#M30464</link>
      <description>&lt;P&gt;I know you can use "--" two hyphens to comment a code line in Toad, but that is not valid in SAS. Change that to enclosing the code in /* code line */.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 20:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-22-322-Syntax-error-with-case-statement/m-p/469744#M30464</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-06-12T20:17:56Z</dc:date>
    </item>
  </channel>
</rss>

