<?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: %let eval in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470530#M285639</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;two columns colA and Colb are present in dataset have and both are numeric. When I use the following I'm getting Error "A Character operand was found in %eval function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let var1=%eval((colA+colB)*colB));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;va1=&amp;amp;var1.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Once again, catastrophic misunderstanding of macro timing. Lots of insights into the force of macro to gain you need, young padawan, before use it you can without harm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro &lt;STRONG&gt;PRE&lt;/STRONG&gt;processor sees only text. The text &lt;FONT face="courier new,courier"&gt;(colA+colB)*colB&lt;/FONT&gt; is nothing numeric that can be evaluated, so the %eval (as it happens immediately in the %let) will fail. I also fail to see the wisdom of packing data step logic into a macro variable. This will only reduce the maintainability of your code.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jun 2018 09:07:22 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-06-15T09:07:22Z</dc:date>
    <item>
      <title>%let eval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470442#M285636</link>
      <description>&lt;P&gt;two columns colA and Colb are present in dataset have and both are numeric. When I use the following I'm getting Error "A Character operand was found in %eval function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let var1=%eval((colA+colB)*colB));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;va1=&amp;amp;var1.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 20:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470442#M285636</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2018-06-14T20:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: %let eval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470444#M285637</link>
      <description>&lt;P&gt;EVAL only works with integers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since you're just passing the arguments you don't need any of that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=(weight+height)*height;

 

data test;

  set sashelp.class;

va1=&amp;amp;var1.;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jun 2018 20:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470444#M285637</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-14T20:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: %let eval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470467#M285638</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;two columns colA and Colb are present &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#3366ff"&gt;in dataset have and both are numeric&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;. When I use the following I'm getting Error "A Character operand was found in %eval function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let var1=%eval((colA+colB)*colB));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;va1=&amp;amp;var1.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Macro functions generally do not reference values of data step variables.&lt;/P&gt;
&lt;P&gt;If you want a statement to appear as data step code:&lt;/P&gt;
&lt;P&gt;%let var1 = ((colA+colB)*colB);&lt;/P&gt;
&lt;P&gt;%eval was attempting to add the text values colA, colB and multiply by the colB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If at some point you are making the code generated dynamic then you would use&lt;/P&gt;
&lt;P&gt;%let var1 = ((&amp;amp;colA+&amp;amp;colB)*&amp;amp;colB);&lt;/P&gt;
&lt;P&gt;where the macro variable &amp;amp;colA and &amp;amp;colB resolve to names of data step variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro code such as this is only evaluated during the compile phase of the data step to generate code lines. Not at the execution of each loop through the data set.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 22:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470467#M285638</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-14T22:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: %let eval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470530#M285639</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;two columns colA and Colb are present in dataset have and both are numeric. When I use the following I'm getting Error "A Character operand was found in %eval function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let var1=%eval((colA+colB)*colB));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;va1=&amp;amp;var1.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Once again, catastrophic misunderstanding of macro timing. Lots of insights into the force of macro to gain you need, young padawan, before use it you can without harm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro &lt;STRONG&gt;PRE&lt;/STRONG&gt;processor sees only text. The text &lt;FONT face="courier new,courier"&gt;(colA+colB)*colB&lt;/FONT&gt; is nothing numeric that can be evaluated, so the %eval (as it happens immediately in the %let) will fail. I also fail to see the wisdom of packing data step logic into a macro variable. This will only reduce the maintainability of your code.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 09:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-eval/m-p/470530#M285639</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-15T09:07:22Z</dc:date>
    </item>
  </channel>
</rss>

