<?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: Case when condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828858#M35467</link>
    <description>&lt;P&gt;If you want to refer to the dataset&amp;nbsp;Telephone_numbers with the alias A then you need to tell SQL that in the FROM clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table Mobile_numbers as
  select a.*
       , case when dr_phone like '07%' then 'Mobile' else 'Landline'
         end as Mobile_or_Landline
  from Telephone_numbers a
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just remove the a. from before the * in the list of variables.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2022 14:20:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-08-16T14:20:29Z</dc:date>
    <item>
      <title>Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828846#M35463</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I have created a table with phone numbers. Now I am trying to divide the phone numbers into mobile and landline numbers. Suppose if the mobile number starts with 07 then I am using the below code but getting some error in the code. Can you please suggest?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Mobile_numbers as
select a.*,
case when dr_phone like (07%)  then 'Mobile' else 'Landline'
end as Mobile_or_Landline
from Telephone_numbers;
quit;

Error:
29         proc sql;
30         create table Mobile_numbers as
31         select a.*,
32         case when dr_phone like (07%)  then 'Mobile' else 'Landline'
                                      _
                                      22
                                      200
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, ^, ^=, |, ||, ~, ~=.  

ERROR 200-322: The symbol is not recognized and will be ignored.

33         end as Mobile_or_Landline
34         from Telephone_numbers;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
35         quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 13:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828846#M35463</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-08-16T13:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828849#M35464</link>
      <description>&lt;P&gt;Is your phone number actually a number or character? If character the syntax would be '07%' to indicate the comparison value.&lt;/P&gt;
&lt;P&gt;If numeric "like" is not going to appropriate at all.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 14:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828849#M35464</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-08-16T14:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828853#M35466</link>
      <description>&lt;P&gt;It's a character value. So I made the changes to '07%' but it still shows the below error.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Mobile_numbers as
select a.*,
case when dr_phone like '07%' then 'Mobile' else 'Landline'
end as Mobile_or_Landline
from Telephone_numbers;
quit;

error:
29         proc sql;
30         create table Mobile_numbers as
31         select a.*,
32         case when dr_phone like '07%' then 'Mobile' else 'Landline'
33         end as Mobile_or_Landline
34         from Telephone_numbers;
ERROR: Could not expand a.*, correlation name not found.
ERROR: The following columns were not found in the contributing tables: a.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
35         quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 14:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828853#M35466</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-08-16T14:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828858#M35467</link>
      <description>&lt;P&gt;If you want to refer to the dataset&amp;nbsp;Telephone_numbers with the alias A then you need to tell SQL that in the FROM clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table Mobile_numbers as
  select a.*
       , case when dr_phone like '07%' then 'Mobile' else 'Landline'
         end as Mobile_or_Landline
  from Telephone_numbers a
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just remove the a. from before the * in the list of variables.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 14:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828858#M35467</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-16T14:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828860#M35468</link>
      <description>&lt;P&gt;Thank you. Got it!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 14:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828860#M35468</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2022-08-16T14:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Case when condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828863#M35469</link>
      <description>case when dr_phone like '(07%)' then 'Mobile' else 'Landline'&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Aug 2022 14:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-condition/m-p/828863#M35469</guid>
      <dc:creator>yaakov555</dc:creator>
      <dc:date>2022-08-16T14:45:30Z</dc:date>
    </item>
  </channel>
</rss>

