<?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: Multiple case when statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845709#M36840</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table Payment_method as 
select a.*,
b.dt_method_a as payment_method,
case when payment_method = 'DD' then 'Direct Debit'
when payment_method in( 'AP' , 'Cash',  'GIRO', 'LIVR', 'PDQ', 'SP' , 'ZAUT' ) then 'Cash'
when payment_method = 'CC' then 'Credit Card'
when payment_method = 'DC' then 'Debit Card'
when payment_method = 'PO' then 'Postal order'
when payment_method = 'SO' then 'Standing order'
else 'No_info' end as Mode_of_payment

from Adding_collections as a
Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;CASE should only be in the statement once&lt;/LI&gt;
&lt;LI&gt;No comma's at end&lt;/LI&gt;
&lt;LI&gt;OR statement is incorrect, need to either list all variables or use IN (in is easier)&lt;/LI&gt;
&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am writing a code with multiple case when statement but I am getting error as 'Expecting an END'. Can you please check the code and let me know what changes do I need to make in the code. I did tried writing end as mode of payment after every case when statement but it only gave me DD as Direct Debit and rest of the option were blank. Thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table Payment_method as 
select a.*,
b.dt_method_a as payment_method,
case when payment_method = 'DD' then 'Direct Debit',
case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash',
case when payment_method = 'CC' then 'Credit Card',
case when payment_method = 'DC' then 'Debit Card',
case when payment_method = 'PO' then 'Postal order',
case when payment_method = 'SO' then 'Standing order'
else 'No_info' end as Mode_of_payment

from Adding_collections as a
Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
quit;

Log:
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
28         
29         Proc sql;
30         create table Payment_method as
31         select a.*,
32         b.dt_method_a as payment_method,
33         case when payment_method = 'DD' then 'Direct Debit',
                                                              _
                                                              73
34         case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash',
                                                                                                               _
                                                                                                               73
35         case when payment_method = 'CC' then 'Credit Card',
                                                             _
                                                             73
36         case when payment_method = 'DC' then 'Debit Card',
                                                            _
                                                            73
37         case when payment_method = 'PO' then 'Postal order',
                                                              _
                                                              73
ERROR 73-322: Expecting an END.

38         case when payment_method = 'SO' then 'Standing order'
39         else 'No_info' end as Mode_of_payment
40         
41         from Adding_collections as a
42         Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
43         quit;
NOTE: The SAS System stopped processing this step because of errors.
2                                                          The SAS System                           09:12 Tuesday, November 22, 2022

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              345.78k
      OS Memory           26712.00k
      Timestamp           11/22/2022 02:34:39 PM
      Step Count                        10  Switch Count  0
      
44         
45         %LET _CLIENTTASKLABEL=;
46         %LET _CLIENTPROCESSFLOWNAME=;
47         %LET _CLIENTPROJECTPATH=;
48         %LET _CLIENTPROJECTPATHHOST=;
49         %LET _CLIENTPROJECTNAME=;
50         %LET _SASPROGRAMFILE=;
51         %LET _SASPROGRAMFILEHOST=;
52         
53         ;*';*";*/;quit;run;
54         ODS _ALL_ CLOSE;
55         
56         
57         QUIT; RUN;
58         
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2022 16:38:38 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-11-22T16:38:38Z</dc:date>
    <item>
      <title>Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845679#M36831</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am writing a code with multiple case when statement but I am getting error as 'Expecting an END'. Can you please check the code and let me know what changes do I need to make in the code. I did tried writing end as mode of payment after every case when statement but it only gave me DD as Direct Debit and rest of the option were blank. Thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table Payment_method as 
select a.*,
b.dt_method_a as payment_method,
case when payment_method = 'DD' then 'Direct Debit',
case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash',
case when payment_method = 'CC' then 'Credit Card',
case when payment_method = 'DC' then 'Debit Card',
case when payment_method = 'PO' then 'Postal order',
case when payment_method = 'SO' then 'Standing order'
else 'No_info' end as Mode_of_payment

from Adding_collections as a
Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
quit;

Log:
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
28         
29         Proc sql;
30         create table Payment_method as
31         select a.*,
32         b.dt_method_a as payment_method,
33         case when payment_method = 'DD' then 'Direct Debit',
                                                              _
                                                              73
34         case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash',
                                                                                                               _
                                                                                                               73
35         case when payment_method = 'CC' then 'Credit Card',
                                                             _
                                                             73
36         case when payment_method = 'DC' then 'Debit Card',
                                                            _
                                                            73
37         case when payment_method = 'PO' then 'Postal order',
                                                              _
                                                              73
ERROR 73-322: Expecting an END.

38         case when payment_method = 'SO' then 'Standing order'
39         else 'No_info' end as Mode_of_payment
40         
41         from Adding_collections as a
42         Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
43         quit;
NOTE: The SAS System stopped processing this step because of errors.
2                                                          The SAS System                           09:12 Tuesday, November 22, 2022

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              345.78k
      OS Memory           26712.00k
      Timestamp           11/22/2022 02:34:39 PM
      Step Count                        10  Switch Count  0
      
44         
45         %LET _CLIENTTASKLABEL=;
46         %LET _CLIENTPROCESSFLOWNAME=;
47         %LET _CLIENTPROJECTPATH=;
48         %LET _CLIENTPROJECTPATHHOST=;
49         %LET _CLIENTPROJECTNAME=;
50         %LET _SASPROGRAMFILE=;
51         %LET _SASPROGRAMFILEHOST=;
52         
53         ;*';*";*/;quit;run;
54         ODS _ALL_ CLOSE;
55         
56         
57         QUIT; RUN;
58         
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Nov 2022 14:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845679#M36831</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-11-22T14:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845684#M36832</link>
      <description>&lt;P&gt;Log is clear, you need to add END statements with CASE, check the documentation for details.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 14:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845684#M36832</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-11-22T14:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845687#M36834</link>
      <description>&lt;P&gt;Yes, that's what I did like&amp;nbsp;case when payment_method = 'DD' then 'Direct Debit' end as Mode_of_payment,&lt;BR /&gt;case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash' end as Mode_of_payment, and so on but then in the mode of payment it is just showing DD as Direct Debit and other options are showing as blank.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 15:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845687#M36834</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-11-22T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845706#M36838</link>
      <description>&lt;P&gt;I should have only one CASE statement and multiple WHEN, no commas are allowed within a single column expression.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 16:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845706#M36838</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-11-22T16:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845709#M36840</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table Payment_method as 
select a.*,
b.dt_method_a as payment_method,
case when payment_method = 'DD' then 'Direct Debit'
when payment_method in( 'AP' , 'Cash',  'GIRO', 'LIVR', 'PDQ', 'SP' , 'ZAUT' ) then 'Cash'
when payment_method = 'CC' then 'Credit Card'
when payment_method = 'DC' then 'Debit Card'
when payment_method = 'PO' then 'Postal order'
when payment_method = 'SO' then 'Standing order'
else 'No_info' end as Mode_of_payment

from Adding_collections as a
Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;CASE should only be in the statement once&lt;/LI&gt;
&lt;LI&gt;No comma's at end&lt;/LI&gt;
&lt;LI&gt;OR statement is incorrect, need to either list all variables or use IN (in is easier)&lt;/LI&gt;
&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am writing a code with multiple case when statement but I am getting error as 'Expecting an END'. Can you please check the code and let me know what changes do I need to make in the code. I did tried writing end as mode of payment after every case when statement but it only gave me DD as Direct Debit and rest of the option were blank. Thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table Payment_method as 
select a.*,
b.dt_method_a as payment_method,
case when payment_method = 'DD' then 'Direct Debit',
case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash',
case when payment_method = 'CC' then 'Credit Card',
case when payment_method = 'DC' then 'Debit Card',
case when payment_method = 'PO' then 'Postal order',
case when payment_method = 'SO' then 'Standing order'
else 'No_info' end as Mode_of_payment

from Adding_collections as a
Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
quit;

Log:
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
28         
29         Proc sql;
30         create table Payment_method as
31         select a.*,
32         b.dt_method_a as payment_method,
33         case when payment_method = 'DD' then 'Direct Debit',
                                                              _
                                                              73
34         case when payment_method = 'AP' or 'Cash' or 'GIRO' or 'LIVR' or 'PDQ' or 'SP' or 'ZAUT' then 'Cash',
                                                                                                               _
                                                                                                               73
35         case when payment_method = 'CC' then 'Credit Card',
                                                             _
                                                             73
36         case when payment_method = 'DC' then 'Debit Card',
                                                            _
                                                            73
37         case when payment_method = 'PO' then 'Postal order',
                                                              _
                                                              73
ERROR 73-322: Expecting an END.

38         case when payment_method = 'SO' then 'Standing order'
39         else 'No_info' end as Mode_of_payment
40         
41         from Adding_collections as a
42         Inner join p2scflow.debt as b on a.debt_code=b.debt_code;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
43         quit;
NOTE: The SAS System stopped processing this step because of errors.
2                                                          The SAS System                           09:12 Tuesday, November 22, 2022

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              345.78k
      OS Memory           26712.00k
      Timestamp           11/22/2022 02:34:39 PM
      Step Count                        10  Switch Count  0
      
44         
45         %LET _CLIENTTASKLABEL=;
46         %LET _CLIENTPROCESSFLOWNAME=;
47         %LET _CLIENTPROJECTPATH=;
48         %LET _CLIENTPROJECTPATHHOST=;
49         %LET _CLIENTPROJECTNAME=;
50         %LET _SASPROGRAMFILE=;
51         %LET _SASPROGRAMFILEHOST=;
52         
53         ;*';*";*/;quit;run;
54         ODS _ALL_ CLOSE;
55         
56         
57         QUIT; RUN;
58         
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 16:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845709#M36840</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-22T16:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845710#M36841</link>
      <description>&lt;P&gt;You appear to only be creating one variable. So you should only need one CASE clause.&lt;/P&gt;
&lt;P&gt;Also it does not make any sense to place the boolean operator OR between two string constants.&amp;nbsp; I suspect you want to use the IN operator instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Payment_method as 
select a.*
     , b.dt_method_a as payment_method
     , case when payment_method = 'DD' then 'Direct Debit'
            when payment_method in ('AP' 'Cash' 'GIRO' 'LIVR' 'PDQ' 'SP' 'ZAUT') then 'Cash'
            when payment_method = 'CC' then 'Credit Card'
            when payment_method = 'DC' then 'Debit Card'
            when payment_method = 'PO' then 'Postal order'
            when payment_method = 'SO' then 'Standing order'
            else 'No_info'
        end as Mode_of_payment
from Adding_collections as a
inner join p2scflow.debt as b
   on a.debt_code=b.debt_code
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 17:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845710#M36841</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-22T17:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple case when statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845719#M36843</link>
      <description>&lt;P&gt;Thank you for&amp;nbsp; clarifying it.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 17:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-case-when-statement/m-p/845719#M36843</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-11-22T17:03:42Z</dc:date>
    </item>
  </channel>
</rss>

