<?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 case when syntax error in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502087#M15588</link>
    <description>&lt;P&gt;Could you please help me to resolve the following syntax error? I'm trying to do this under expression in SAS DI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when KNKBTY = '1' then TBFR10.AGI
5             when KNKBTY = '2' then QISFR10.AGI
6             when QISFR10.AGI=. then TBFR10.AGI
7             end
8             end
              ___
              22
              76
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, BETWEEN, 
              CONTAINS, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT, HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, 
              NOTIN, OR, ORDER, OUTER, UNION, ^, ^=, |, ||, ~, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

9             end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 06 Oct 2018 05:24:43 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2018-10-06T05:24:43Z</dc:date>
    <item>
      <title>case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502087#M15588</link>
      <description>&lt;P&gt;Could you please help me to resolve the following syntax error? I'm trying to do this under expression in SAS DI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when KNKBTY = '1' then TBFR10.AGI
5             when KNKBTY = '2' then QISFR10.AGI
6             when QISFR10.AGI=. then TBFR10.AGI
7             end
8             end
              ___
              22
              76
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, BETWEEN, 
              CONTAINS, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT, HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, 
              NOTIN, OR, ORDER, OUTER, UNION, ^, ^=, |, ||, ~, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

9             end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Oct 2018 05:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502087#M15588</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-06T05:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502091#M15589</link>
      <description>&lt;P&gt;A case in SQL needs only one end.&lt;/P&gt;
&lt;P&gt;Read the documentation.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 06:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502091#M15589</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-06T06:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502094#M15590</link>
      <description>If you use the Join transformation, it comes with a point-and-click interface for case statement. It's not super smooth, but try it out, at least as a way of learning the syntax.</description>
      <pubDate>Sat, 06 Oct 2018 08:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502094#M15590</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-10-06T08:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502095#M15591</link>
      <description>Yes I'm using Join transformation but I'm not sure how to use the point and&lt;BR /&gt;click interface to know the syntax.&lt;BR /&gt;</description>
      <pubDate>Sat, 06 Oct 2018 09:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502095#M15591</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-10-06T09:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502111#M15592</link>
      <description>You read the documentation to understand the syntax.</description>
      <pubDate>Sat, 06 Oct 2018 13:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502111#M15592</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-06T13:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502278#M15593</link>
      <description>&lt;P&gt;Your CASE statement should be as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Your case statement should be something like this:&lt;BR /&gt;&lt;BR /&gt;Select&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;case KNKBTY&lt;BR /&gt;when &lt;SPAN class="token string"&gt;'1'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; TBFR10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;AGI
&lt;SPAN class="token number"&gt;when &lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'2'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; QISFR10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;AGI
else "something"&lt;BR /&gt;end as KNKBTY&lt;BR /&gt;.....&lt;BR /&gt;&lt;BR /&gt;In DI Studio, In Expression select "CASE"&lt;BR /&gt;In Operand: select column (KNKBTY)&lt;BR /&gt;Click on New to enter a condition&lt;BR /&gt;Enter your condition in "WHEN Condition", Enter Result in THEN Result&lt;BR /&gt;&lt;BR /&gt;Like other user users are suggesting please refer to doc for more information.&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 21:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502278#M15593</guid>
      <dc:creator>VenuKadari</dc:creator>
      <dc:date>2018-10-07T21:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502289#M15594</link>
      <description>&lt;P&gt;Are you trying your own SAS code into SAS/DI ?&amp;nbsp; If so then sure to use valid syntax.&amp;nbsp; If you are making a program code file then indentation will make it easier for you to verify you have used valid syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case
  when KNKBTY = '1' then TBFR10.AGI
  when KNKBTY = '2' then QISFR10.AGI
  when QISFR10.AGI=. then TBFR10.AGI
  else .
end&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For that to work it needs to be part of a valid SQL statement.&amp;nbsp; Perhaps you are using it as one of the variables in a SELECT statement?&amp;nbsp; If so then you need to give the new variable a name. So you full SQL statement might look something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 
  KNKBTY
, QIDFR10.AGI
, case
    when KNKBTY = '1' then TBFR10.AGI
    when KNKBTY = '2' then QISFR10.AGI
    when QISFR10.AGI=. then TBFR10.AGI
    else .
  end as NEW_VAR
from TBFR10
inner join QISFR10
  on QISFR10.id = TBFR10.id
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 00:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502289#M15594</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-08T00:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: case when syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502296#M15596</link>
      <description>&lt;P&gt;DIS adds the end statement for you so don't have it in your expression. You just need to define the CASE bit in the expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 02:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/case-when-syntax-error/m-p/502296#M15596</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-08T02:14:37Z</dc:date>
    </item>
  </channel>
</rss>

