<?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: Like operator requires character operands in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861138#M38045</link>
    <description>Even with 120 I am getting the same error message.</description>
    <pubDate>Mon, 27 Feb 2023 16:20:48 GMT</pubDate>
    <dc:creator>Sandeep77</dc:creator>
    <dc:date>2023-02-27T16:20:48Z</dc:date>
    <item>
      <title>Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861124#M38040</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am trying to find the data with 120A&amp;nbsp; but when I am using the where function I am getting the below error message. The&amp;nbsp;AccountStatusKey_Current is Numeric type. Do I need to change the type to character? if so then how can I do it?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table Accountstatus as 
select AccountKey,
AccountStatusKey_Current,
AccountStatusKey_Previous,
Datekey
from DWHDW.fact_tx_AccountStatus
where AccountStatusKey_Current like '120A';
quit;

Error log:



29         Proc sql;
30         create table Accountstatus as
31         select AccountKey,
32         AccountStatusKey_Current,
33         AccountStatusKey_Previous,
34         Datekey
35         from DWHDW.fact_tx_AccountStatus
36         where AccountStatusKey_Current like '120A';
ERROR: LIKE operator requires character operands.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
37         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.09 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              5457.43k
      OS Memory           42680.00k
      Timestamp           02/27/2023 03:53:00 PM
      Step Count                        53  Switch Count  16&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 15:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861124#M38040</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T15:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861126#M38041</link>
      <description>&lt;P&gt;AccountStatusKey_Current must be numeric, otherwise you would not get that message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can convert it to character with the PUT function, but don't bother, a number (if converted to character) cannot be&amp;nbsp;&lt;FONT face="courier new,courier"&gt;like '120A'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;which should always fail. You have, in addition to the syntax error, a logic error which you must fix first&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861126#M38041</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-27T16:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861132#M38042</link>
      <description>&lt;P&gt;Thank you but I did not get it. So should I use&amp;nbsp;where AccountStatusKey_Current = '120A' instead of like? Also should I use the put statement in between my code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861132#M38042</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T16:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861135#M38043</link>
      <description>If AccountStatusKey_Current is numeric, it can never have the letter A in it. &lt;BR /&gt;&lt;BR /&gt;So you need to verify your request as it will never be true. Is it the correct variable you're referencing?</description>
      <pubDate>Mon, 27 Feb 2023 16:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861135#M38043</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-27T16:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861137#M38044</link>
      <description>&lt;P&gt;Okay, I got it. Yes, my mistake. Actually it is just &lt;SPAN&gt;AccountStatusKey_Current&amp;nbsp; is&lt;/SPAN&gt;120 and not 120A.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861137#M38044</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T16:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861138#M38045</link>
      <description>Even with 120 I am getting the same error message.</description>
      <pubDate>Mon, 27 Feb 2023 16:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861138#M38045</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T16:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861140#M38046</link>
      <description>&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;Thank you but I did not get it. So should I use&amp;nbsp;where AccountStatusKey_Current = '120A' instead of like? Also should I use the put statement in between my code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A number cannot be equal to '120A' either.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861140#M38046</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-27T16:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861141#M38047</link>
      <description>&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;Even with 120 I am getting the same error message.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have to convert the numeric variable AccountStatusKey_Current to character with the PUT function.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861141#M38047</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-27T16:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861143#M38048</link>
      <description>&lt;P&gt;So this error&lt;/P&gt;
&lt;PRE&gt;36         where AccountStatusKey_Current like '120A';
ERROR: LIKE operator requires character operands.&lt;/PRE&gt;
&lt;P&gt;means that&amp;nbsp;AccountStatusKey_Current is a numeric variable.&amp;nbsp; Hence the error message about needing a character operand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that if&amp;nbsp;AccountStatusKey_Current is a number can never have the letter A as part of its value.&amp;nbsp; So it can never be equal to the string '120A'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you instead want to test if the the value as 120?&amp;nbsp; Do you have a format attached to that variable that makes it display strings that include the letter A?&amp;nbsp; If so you need to test for the actual value not the formatted value.&amp;nbsp; Or use the PUT() function to convert the number to the formatted value and then you can check if that formatted value looks like what you are looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Plus if you are testing for a single value like 120 or '120A' you do not need to use LIKE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead just use =&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where AccountStatusKey_Current ='120A';
where AccountStatusKey_Current = 120;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you have list of distinct values use IN&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where AccountStatusKey_Current in ('120A' '130B');
where AccountStatusKey_Current in (120 130) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861143#M38048</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-27T16:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator requires character operands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861148#M38049</link>
      <description>&lt;P&gt;Thank you Tom. I understood it now. I was making the mistake of using '120'.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Like-operator-requires-character-operands/m-p/861148#M38049</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T16:47:19Z</dc:date>
    </item>
  </channel>
</rss>

