<?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: Sanity Check - Lack of %eval() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188531#M265869</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%eval is to resolve integer arithmetic with macro variables. You have created data step syntax which resolves as it should.&lt;/P&gt;&lt;P&gt;Since each of your macro variables apparently resolve to numbers you are generating syntax like&amp;nbsp;&amp;nbsp;&amp;nbsp; 9/45 which the data step processes as a division statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jul 2014 20:10:45 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-07-21T20:10:45Z</dc:date>
    <item>
      <title>Sanity Check - Lack of %eval()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188530#M265868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following code which I managed to run and get desirable results. I did not expect to be able to run the code below, however, because I do not use the %eval() function when evaluating the ratios in the last datastep. Without the %eval(), shouldn't the ratios be evaluated as characters and shouldn't I be getting an ERROR as a result?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone please provide a sanity check?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro count_runoff_all;&lt;BR /&gt; &lt;BR /&gt;%do i= 1 %to 9;&lt;/P&gt;&lt;P&gt;proc sql ;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;select count(psts3)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;into :n_def_runoff&amp;amp;i.&lt;/P&gt;&lt;P&gt;from runoff_all&amp;amp;i&lt;/P&gt;&lt;P&gt;where psts3="n6";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put n_def_runoff1 value is: &amp;amp;n_def_runoff1;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff2;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff3;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff4;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff5;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff6;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff7;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff8;&lt;BR /&gt;%put n_def_runoff2 value is: &amp;amp;n_def_runoff9;&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;data default_runoff_all;&lt;/P&gt;&lt;P&gt; set runoff9;&lt;/P&gt;&lt;P&gt; randv=rand("Uniform"); &lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; if randv &amp;lt; &amp;amp;n_def_runoff1/&amp;amp;n_def_runoff9 then quarter = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff2/&amp;amp;n_def_runoff9 then quarter = 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff3/&amp;amp;n_def_runoff9 then quarter = 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff4/&amp;amp;n_def_runoff9 then quarter = 4;&lt;BR /&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff5/&amp;amp;n_def_runoff9 then quarter = 5;&lt;BR /&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff6/&amp;amp;n_def_runoff9 then quarter = 6;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff7/&amp;amp;n_def_runoff9 then quarter = 7;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if randv &amp;lt; &amp;amp;n_def_runoff8/&amp;amp;n_def_runoff9 then quarter = 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else quarter = 9;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; n_def_runoff1_ratio=&amp;amp;n_def_runoff1/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff2_ratio=&amp;amp;n_def_runoff2/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff3_ratio=&amp;amp;n_def_runoff3/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff4_ratio=&amp;amp;n_def_runoff4/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff5_ratio=&amp;amp;n_def_runoff5/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff6_ratio=&amp;amp;n_def_runoff6/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff7_ratio=&amp;amp;n_def_runoff7/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; n_def_runoff8_ratio=&amp;amp;n_def_runoff8/&amp;amp;n_def_runoff9;&lt;BR /&gt;&amp;nbsp; /*drop fcst_mon draw randv n_def_runoff1_ratio n_def_runoff2_ratio n_def_runoff3_ratio n_def_runoff4_ratio n_def_runoff5_ratio&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; n_def_runoff6_ratio n_def_runoff7_ratio n_def_runoff8_ratio;*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend; &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%count_runoff_all;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 19:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188530#M265868</guid>
      <dc:creator>maroulator</dc:creator>
      <dc:date>2014-07-21T19:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sanity Check - Lack of %eval()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188531#M265869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%eval is to resolve integer arithmetic with macro variables. You have created data step syntax which resolves as it should.&lt;/P&gt;&lt;P&gt;Since each of your macro variables apparently resolve to numbers you are generating syntax like&amp;nbsp;&amp;nbsp;&amp;nbsp; 9/45 which the data step processes as a division statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 20:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188531#M265869</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-07-21T20:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sanity Check - Lack of %eval()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188532#M265870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Huh?&amp;nbsp; I do not see any macro conditional logic there that would require %EVAL().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This line of code is just generating a simple SAS statement. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; if randv &amp;lt; &amp;amp;n_def_runoff1/&amp;amp;n_def_runoff9 then quarter = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;So if those two macro variables evaluate to 3 and 103 , respectively, then it is the same as if you wrote&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt; if randv &amp;lt; 3/103 then quarter = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS knows how to divide numeric constants.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 20:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sanity-Check-Lack-of-eval/m-p/188532#M265870</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-21T20:14:01Z</dc:date>
    </item>
  </channel>
</rss>

