<?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: Strange %eval error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134334#M27291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right issue, right solution.&amp;nbsp; You might be seeing how this plays out, but I'm not sure.&amp;nbsp; Inside a macro, the condition is %eval(132-1;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Outside a macro, the condition is %eval(132-1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In both cases, the original code generates something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start_mod = %eval( (201201 - 201201/100 * 100);;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've taken out all the extra %evals, since they are not really needed.&amp;nbsp; But the difference is this.&amp;nbsp; Outside of a macro, the first semicolon ends the %let statement.&amp;nbsp; The second just becomes a null statement.&amp;nbsp; Inside a macro, the second semicolon ends the %let statement.&amp;nbsp; The first becomes part of the value of &amp;amp;START_MOD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 May 2013 23:58:12 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-05-16T23:58:12Z</dc:date>
    <item>
      <title>Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134328#M27285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok so I have this code to calculate months between a numeric date range: &lt;/P&gt;&lt;P&gt; Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start_month = 200201;&lt;/P&gt;&lt;P&gt;%let end_month = 201301;&lt;/P&gt;&lt;P&gt;%let second_end_month = 201212;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start_yr = %eval(&amp;amp;start_month. / 100);&lt;/P&gt;&lt;P&gt;%let end_yr = %eval(&amp;amp;end_month. / 100);&lt;/P&gt;&lt;P&gt;%let start_mod = %modulo(&amp;amp;start_month.,100);&lt;/P&gt;&lt;P&gt;%let end_mod = %modulo(&amp;amp;end_month.,100);&lt;/P&gt;&lt;P&gt; %let yr_dif = %eval(&amp;amp;end_yr. - &amp;amp;start_yr.);&lt;/P&gt;&lt;P&gt;%let nmonths = %eval(12 * &amp;amp;yr_dif.);&lt;/P&gt;&lt;P&gt;%let temp1 = %eval(&amp;amp;nmonths - &amp;amp;start_mod.); &lt;/P&gt;&lt;P&gt;%let temp2 = %eval(&amp;amp;temp1 + &amp;amp;end_mod.);&lt;/P&gt;&lt;P&gt;%let num_observations = %eval(&amp;amp;temp2 + 1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is within a macro being called within my program, which sets different date ranges dependent on the current data being processed.&lt;/P&gt;&lt;P&gt;When I run this selection of code, it runs fine, and outputs the correct value when I check witha %put statement (133). However When I just run my entire program (which has been operating for some time without error, and this is the only piece of code added since), I receive the error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is required. The condition was: 132 - 1; &lt;/P&gt;&lt;P&gt;ERROR: The macro SET_PRODUCT_SPECIFICS will stop executing. "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't understand this error, I don't understand why it is occuring in the same piece of code when run with the entire program, but not when the selection is run alone, also I don't see why "132-1" is not valid input for %eval().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Ryan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 18:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134328#M27285</guid>
      <dc:creator>AllSoEasy</dc:creator>
      <dc:date>2013-05-16T18:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134329#M27286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is %modulo?&amp;nbsp; Is it another macro?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 19:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134329#M27286</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-05-16T19:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134330#M27287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro modulo(a, b);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%eval(&amp;amp;a - %eval(%eval(&amp;amp;a/&amp;amp;b) * &amp;amp;b)); &lt;/P&gt;&lt;P&gt;%mend;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we can see that that macro is not the issue because all of the lines execute properly up until &lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%let temp1 = %eval(&amp;amp;nmonths - &amp;amp;start_mod.); &lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; - which actually throws the error, after the preceding statement have resolved (if the modulo function did not work it wouldn't be passing in "132-1" on the error line, which are correct numbers from the preceding calculations.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 20:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134330#M27287</guid>
      <dc:creator>AllSoEasy</dc:creator>
      <dc:date>2013-05-16T20:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134331#M27288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove the semi-colon, in the modulo macro, in it's %eval line.&amp;nbsp; i.e., make it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro modulo(a, b);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%eval(&amp;amp;a - %eval(%eval(&amp;amp;a/&amp;amp;b) * &amp;amp;b))&lt;/P&gt;&lt;P&gt;%mend; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 20:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134331#M27288</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-05-16T20:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134332#M27289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In light of everything, does the code work fine when you run it in open code, but cause problems when you run it inside a macro definition?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 20:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134332#M27289</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-05-16T20:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134333#M27290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="5253" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: That is why I recommended that the OP remove the semicolon from within the function style macro that the initially posted set of %let statements .. inside a macro .. returns an error: &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The condition was: 132 - 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a %eval of 132-1;&amp;nbsp;&amp;nbsp; will fail in a macro even though it would work in open code.&amp;nbsp; The semicolon at the end of the one line in the modulo macro will cause it to fail when called from within a macro.&amp;nbsp; If the OP removes it, it will work both in open code and in a macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 22:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134333#M27290</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-05-16T22:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Strange %eval error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134334#M27291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right issue, right solution.&amp;nbsp; You might be seeing how this plays out, but I'm not sure.&amp;nbsp; Inside a macro, the condition is %eval(132-1;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Outside a macro, the condition is %eval(132-1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In both cases, the original code generates something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start_mod = %eval( (201201 - 201201/100 * 100);;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've taken out all the extra %evals, since they are not really needed.&amp;nbsp; But the difference is this.&amp;nbsp; Outside of a macro, the first semicolon ends the %let statement.&amp;nbsp; The second just becomes a null statement.&amp;nbsp; Inside a macro, the second semicolon ends the %let statement.&amp;nbsp; The first becomes part of the value of &amp;amp;START_MOD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 23:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Strange-eval-error/m-p/134334#M27291</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-05-16T23:58:12Z</dc:date>
    </item>
  </channel>
</rss>

