<?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: How can I solve the error: WHERE clause operator requires compatible variables. in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846599#M827</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This happens because the variable bill_mth is numeric, and you cannot compare numeric values to character strings such as 'JUL' or 'DEC'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely, you don't want the character strings in the comparison, but that really depends on the values in variable BILL_MTH. So what are some of the values in variable BILL_MTH?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also, note that 'DEC' is less than 'JUL' and so&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where 'JUL'&amp;lt;=bill_mth&amp;lt;='DEC'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can never be true. Character strings are compared alphabetically, so the first month of the year would be 'APR' and the second month would be 'AUG' and so on using character strings, which is not what most people want.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 13:30:59 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-11-28T13:30:59Z</dc:date>
    <item>
      <title>How can I solve the error: WHERE clause operator requires compatible variables.</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846591#M826</link>
      <description>&lt;P&gt;the question is this:&lt;/P&gt;&lt;P&gt;What is the monthly grand total of billing amounts between 1 July 2011 and 31 December 2011? Write statements of one PROC only such that it will report the grand total of billing amounts for each month between 1 July 2011 and 31 December 2011. The report must show each monthly grand total without requiring further manual computations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is this:&lt;/P&gt;&lt;P&gt;proc print data=SAS.ACCOUNTS&lt;BR /&gt;grandtotal_label='total';&lt;BR /&gt;var amount_topay;&lt;BR /&gt;sumby amount_topay;&lt;BR /&gt;where 'JUL'&amp;lt;=bill_mth&amp;lt;='DEC';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However it occur the error:WHERE clause operator requires compatible variables.&lt;/P&gt;&lt;P&gt;How to solve this?thank you&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 12:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846591#M826</guid>
      <dc:creator>lunaa</dc:creator>
      <dc:date>2022-11-28T12:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I solve the error: WHERE clause operator requires compatible variables.</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846599#M827</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This happens because the variable bill_mth is numeric, and you cannot compare numeric values to character strings such as 'JUL' or 'DEC'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely, you don't want the character strings in the comparison, but that really depends on the values in variable BILL_MTH. So what are some of the values in variable BILL_MTH?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also, note that 'DEC' is less than 'JUL' and so&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where 'JUL'&amp;lt;=bill_mth&amp;lt;='DEC'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can never be true. Character strings are compared alphabetically, so the first month of the year would be 'APR' and the second month would be 'AUG' and so on using character strings, which is not what most people want.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 13:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846599#M827</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-28T13:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I solve the error: WHERE clause operator requires compatible variables.</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846600#M828</link>
      <description>&lt;P&gt;the value in BILL_MTH is like this :&amp;nbsp;&lt;SPAN&gt;2011JAN&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 13:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846600#M828</guid>
      <dc:creator>lunaa</dc:creator>
      <dc:date>2022-11-28T13:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I solve the error: WHERE clause operator requires compatible variables.</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846601#M829</link>
      <description>&lt;P&gt;Great, but that's not a number. It is possible that this is a formatted value, and that unformatted value is something different? Can you remove the format from this variable and tell us some values of this variable?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also, is it really 2011JAN or is it really JAN2011?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 14:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846601#M829</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-28T14:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I solve the error: WHERE clause operator requires compatible variables.</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846610#M830</link>
      <description>&lt;P&gt;Here is an example where the dates are stored as character strings - you'll need to create a new numeric date variable &amp;amp; then you can use where statement on the numeric variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Creating a dataset with a character date variable */&lt;BR /&gt;data mons_char;&lt;BR /&gt;input dt $7.;&lt;BR /&gt;datalines;&lt;BR /&gt;jul2022&lt;BR /&gt;jun2022&lt;BR /&gt;aug2022&lt;BR /&gt;jan2022&lt;BR /&gt;feb2022&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/* Creating a numeric date variable using the input function - using formats to show how that new variable can be displayed */&lt;BR /&gt;data mons2;&lt;BR /&gt;set mons_char;&lt;BR /&gt;format dt_num2 monyy7. dt_num3 date9.;&lt;BR /&gt;dt_num = input(dt,monyy7.);&lt;BR /&gt;dt_num2 = dt_num;&lt;BR /&gt;dt_num3 = dt_num;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/* Using numeric date variable in where statement */&lt;/P&gt;
&lt;P&gt;proc print data=mons2;&lt;BR /&gt;where '01jun2022'd &amp;lt;= dt_num &amp;lt;= '31aug2022'd;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 14:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-solve-the-error-WHERE-clause-operator-requires/m-p/846610#M830</guid>
      <dc:creator>tom_grant</dc:creator>
      <dc:date>2022-11-28T14:40:01Z</dc:date>
    </item>
  </channel>
</rss>

