<?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 condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818160#M34601</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I have created a dataset where there are telephone numbers in 3 columns. Now I want to use the case when functions. If the telephone number is available in any three column then end as 'Y' else 'N'. I am not very sure if I can do it together. Can you please look at my code as I am getting error. I feel that it's more than a syntax error.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Telephone_numbers as 
select distinct
a.*,
b.dr_phone,
b.dr_phone2,
b.dr_phone3,
case when
b.dr_phone, b.dr_phone2, b.dr_phone3 is not null then 'Y' else 'N'
end as Number_available
from repcodes as a
inner join
p2scflow.debtor as b on a.accounts_number=b.debt_code; 
quit;

Error:

NOTE: Writing HTML5(EGHTML) Body file: EGHTML
28         
29         proc sql;
30         create table Telephone_numbers as
31         select distinct
32         a.*,
33         b.dr_phone,
34         b.dr_phone2,
35         b.dr_phone3,
36         case when
37         b.dr_phone, b.dr_phone2, b.dr_phone3 is not null then 'Y' else 'N'
                     _
                     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, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, 
              ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

38         end as Number_available
39         from repcodes as a
40         inner join
41         p2scflow.debtor as b on a.accounts_number=b.debt_code;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
42         quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Jun 2022 17:17:05 GMT</pubDate>
    <dc:creator>Sandeep77</dc:creator>
    <dc:date>2022-06-14T17:17:05Z</dc:date>
    <item>
      <title>Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818160#M34601</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I have created a dataset where there are telephone numbers in 3 columns. Now I want to use the case when functions. If the telephone number is available in any three column then end as 'Y' else 'N'. I am not very sure if I can do it together. Can you please look at my code as I am getting error. I feel that it's more than a syntax error.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Telephone_numbers as 
select distinct
a.*,
b.dr_phone,
b.dr_phone2,
b.dr_phone3,
case when
b.dr_phone, b.dr_phone2, b.dr_phone3 is not null then 'Y' else 'N'
end as Number_available
from repcodes as a
inner join
p2scflow.debtor as b on a.accounts_number=b.debt_code; 
quit;

Error:

NOTE: Writing HTML5(EGHTML) Body file: EGHTML
28         
29         proc sql;
30         create table Telephone_numbers as
31         select distinct
32         a.*,
33         b.dr_phone,
34         b.dr_phone2,
35         b.dr_phone3,
36         case when
37         b.dr_phone, b.dr_phone2, b.dr_phone3 is not null then 'Y' else 'N'
                     _
                     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, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, 
              ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

38         end as Number_available
39         from repcodes as a
40         inner join
41         p2scflow.debtor as b on a.accounts_number=b.debt_code;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
42         quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jun 2022 17:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818160#M34601</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-06-14T17:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818162#M34603</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when b.dr_phone is not null or b.dr_phone2 is not null or b.dr_phone3 is not null then 'Y' else 'N'&amp;nbsp;end&amp;nbsp;as&amp;nbsp;variable_name&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or simpler&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when coalesce(b.dr_phone,b.dr_phone2,b.dr_phone3) is not null then 'Y' else 'N' end as variable_name&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Commas, like in your code, are only used to separate variables in the SELECT clause. They don't belong in CASE statements (except at the end after you have &lt;FONT face="courier new,courier"&gt;end as variable_name&lt;/FONT&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 17:31:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818162#M34603</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-14T17:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818170#M34605</link>
      <description>Thank you!!</description>
      <pubDate>Tue, 14 Jun 2022 17:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/818170#M34605</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-06-14T17:46:53Z</dc:date>
    </item>
  </channel>
</rss>

