<?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 to add numbers using %eval? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227788#M41078</link>
    <description>&lt;P&gt;You need to show more of the context of your program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are working in a DATA step, all the %EVALs can go. &amp;nbsp;The DATA step never uses them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are not working in a DATA step, _N_ does not exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In either case, adding parentheses might help clarify your intention.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2015 23:44:43 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-09-29T23:44:43Z</dc:date>
    <item>
      <title>How to add numbers using %eval?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227620#M41024</link>
      <description>&lt;P&gt;I've a code like below,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if %eval(&amp;amp;end_title)+%eval(&amp;amp;end_title1&amp;lt;_n_&amp;lt;%eval(&amp;amp;end_title)+%eval(&amp;amp;end_title1)+%eval(&amp;amp;end_title2) then do; put option;end&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 1558&amp;lt;_n_&amp;lt;1558+1558+1558&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone tell me how to sum&amp;nbsp;&amp;nbsp;using %eval?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 09:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227620#M41024</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-29T09:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to add numbers using %eval?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227623#M41025</link>
      <description>&lt;P&gt;Why do you need to add so many evals? the logic function should work on the same way without it. Even though, if you want to add the %eval function, if macro variables END_TITLE, END_TITLE1 and END_TITLE2 are numeric should work. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if %eval(&amp;amp;end_title +&amp;amp;end_title1) &amp;lt; _n_ &amp;lt; %eval(&amp;amp;end_title+&amp;amp;end_title1+&amp;amp;end_title2) then do; put option;end&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In words, what do you want to do with this condition?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 09:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227623#M41025</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-09-29T09:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to add numbers using %eval?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227626#M41026</link>
      <description>&lt;P&gt;Your mixing boolean logic &amp;amp;end_title1 &amp;lt; _n_ &amp;lt; ..., with numerical operations %eval(). &amp;nbsp;Again, as per several other posts, why are you trying to do all this in macro language. &amp;nbsp;Your clearly trying to force programming through macro. &amp;nbsp;Step back and just write base SAS code to do what you want. &amp;nbsp;If you see repeats of code, then put that in a macro, but don't try to program everything in macro code its crazy.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 10:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227626#M41026</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-29T10:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add numbers using %eval?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227679#M41039</link>
      <description>&lt;P&gt;As others have mentioned, your code is unusual.&amp;nbsp; It is rare to use the %EVAL macro function on a data step IF statement.&amp;nbsp; %EVAL is for doing integer arithmetic in the macro language. The DATA step language does not need it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said, I'm surprised you are getting an error message.&amp;nbsp; The below sample code "works".&amp;nbsp; It is possible you have some unprintable characters in your actual example, or even decimal points.&amp;nbsp; Second DATA step shows that %EVAL is not needed in this setting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let end_title=1;
%let end_title1=2;
%let end_title2=3;


data _null_;
  set sashelp.class;
  if %eval(&amp;amp;end_title +&amp;amp;end_title1) &amp;lt; _n_ &amp;lt; %eval(&amp;amp;end_title+&amp;amp;end_title1+&amp;amp;end_title2) then do;
    put _n_=;
  end;
run;


data _null_;
  set sashelp.class;
  if (&amp;amp;end_title +&amp;amp;end_title1) &amp;lt; _n_ &amp;lt; (&amp;amp;end_title+&amp;amp;end_title1+&amp;amp;end_title2) then do;
    put _n_=;
  end;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227679#M41039</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-09-29T14:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add numbers using %eval?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227788#M41078</link>
      <description>&lt;P&gt;You need to show more of the context of your program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are working in a DATA step, all the %EVALs can go. &amp;nbsp;The DATA step never uses them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are not working in a DATA step, _N_ does not exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In either case, adding parentheses might help clarify your intention.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 23:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-numbers-using-eval/m-p/227788#M41078</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-09-29T23:44:43Z</dc:date>
    </item>
  </channel>
</rss>

