<?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: A character operand was found in the %EVAL function or %IF condition in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228957#M16682</link>
    <description>&lt;P&gt;As has been noted, detecting date variables properly is a separate question and that issue needs some work.&amp;nbsp; In the meantime, to address the error, try it this way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if %LENGTH(&amp;amp;var.) &amp;gt; 8 AND %sysfunc(VARTYPE(&amp;amp;dsid.,%sysfunc(VARNUM(&amp;amp;dsid.,&amp;amp;var.))))=N %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that the quotes around N are removed!&lt;/P&gt;</description>
    <pubDate>Wed, 07 Oct 2015 18:22:58 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-10-07T18:22:58Z</dc:date>
    <item>
      <title>A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228933#M16676</link>
      <description>&lt;P&gt;/* Here is the code that is having an issue*/&lt;/P&gt;&lt;P&gt;%macro numstats(var = ,file=, format=);&lt;BR /&gt;%let dsid=open(&amp;amp;file.,i);&lt;BR /&gt;%if %LENGTH(&amp;amp;var.) &amp;gt; 8 AND %VARTYPE(&amp;amp;dsid.,%VARNUM(&amp;amp;dsid.,&amp;amp;var.))='N' %then %do;&lt;BR /&gt;Proc SQL;&lt;/P&gt;&lt;P&gt;SQL code&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;%mend numstats;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having the following error when running this code:&amp;nbsp;A character operand was found in the %EVAL function or %IF condition where a numeric operand is required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have played with this code extensively to try different online solutions and cannot figure out why I am still receiving this issue. Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Side Note: The reason I had to add this IF statement is to try to find out whether the variable was a date variable. All my date variables are Date9. so if it is Numeric and has a length greater than 8, then I want to add date formatting that I would not add to regular numeric variables. If anyone can think of an easier way to do that, then i am open to that as well, but please help me figure out this error!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 16:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228933#M16676</guid>
      <dc:creator>SAS_N00b</dc:creator>
      <dc:date>2015-10-07T16:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228936#M16677</link>
      <description>Can you post your the code for the %VARTYPE and %VARNUM macros you call? Note that it's a good idea to CLOSE() the dataset at the end of your macro. Also note that %if %Length(&amp;amp;var)&amp;gt;8 will test whether the name if the variable is more than 8 characters. That is, if you call %NumStats(var=Fred) then &amp;amp;var would have a length of 4 (because Fred is four characters long). Sounds like that might not be what you want.</description>
      <pubDate>Wed, 07 Oct 2015 17:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228936#M16677</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-10-07T17:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228940#M16678</link>
      <description>&lt;P&gt;The macro processor %IF works a little different than the data datastep IF and you may need to provide additional paratheses to get the order of evaluation correct. I think that it is processing AND %VARTYPE results (numeric and chracter) not the result of (%vartype() = 'N').&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228940#M16678</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-07T17:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228948#M16680</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The %VARTYPE and %VARNUM are not macros that I am calling, but I thought were needed in the same way that I need %IF rather than just an IF statement. If this is not true, please let me know. This was a new concept to me that I was not sure about, but came across when researching solutions on the web.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I am wanting to know whether the length of the field in general is greater than 8, rather than the specific variable name. How would I alter that? I thought it would be understandable because it is not in quotes. Please give a solution if you are aware of a fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228948#M16680</guid>
      <dc:creator>SAS_N00b</dc:creator>
      <dc:date>2015-10-07T17:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228949#M16681</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1106"&gt;@BA﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially, the AND was causing issues and I was getting a slightly different issue. I will try to dig through the differences in syntax between %IF vs. IF online. Thank you for the heads up.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 17:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228949#M16681</guid>
      <dc:creator>SAS_N00b</dc:creator>
      <dc:date>2015-10-07T17:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228957#M16682</link>
      <description>&lt;P&gt;As has been noted, detecting date variables properly is a separate question and that issue needs some work.&amp;nbsp; In the meantime, to address the error, try it this way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if %LENGTH(&amp;amp;var.) &amp;gt; 8 AND %sysfunc(VARTYPE(&amp;amp;dsid.,%sysfunc(VARNUM(&amp;amp;dsid.,&amp;amp;var.))))=N %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that the quotes around N are removed!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 18:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228957#M16682</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-10-07T18:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: A character operand was found in the %EVAL function or %IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228987#M16683</link>
      <description>&lt;P&gt;Ahh, well looks like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;has already guessed the answer to the main part of your question.&amp;nbsp; When you say %VarType and %VarNum are not macro calls, they in fact are.&amp;nbsp; And in your log before the error message you should have seen:&lt;/P&gt;&lt;P&gt;WARNING: Apparent invocation of macro VARTYPE not resolved.&lt;/P&gt;&lt;P&gt;That is SAS's way of telling you that you tried to call a macro that doesn't exist.&amp;nbsp; And so it just leaves the macro call there, and that is causing the error for your %IF statement.&amp;nbsp; You can call these functions by nesting them in %SYSFUNC().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sounds like you might be better off checking to see if the variable is formatted as DATE9, with something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%if %sysfunc(VARFMT(&amp;amp;dsid.,%sysfunc(VARNUM(&amp;amp;dsid.,&amp;amp;var))))=DATE9. %then %put found a date var!;&lt;/PRE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2015 19:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/A-character-operand-was-found-in-the-EVAL-function-or-IF/m-p/228987#M16683</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-10-07T19:50:50Z</dc:date>
    </item>
  </channel>
</rss>

