<?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: Evaluating a macro variable in a condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548514#M8539</link>
    <description>&lt;P&gt;If the only purpose of the test of the value is place a note in the log then do it in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symputx ('E',a_var_e);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symputx ('U2',a_var_u2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if not (&amp;nbsp;0.000 1&amp;lt;&amp;nbsp;a_var_e / a_var_u2&amp;nbsp;le 10) then put "&amp;nbsp;NOTE: Ratio in [0,10] ";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else put "&amp;nbsp;ERROR: Ratio not in [0,10], consider removing extreme observations";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not using the macro variables E and U2 for anything else then don't create them and just use the PUT in the data _null_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have other uses for the comparison then you would be better off creating a flag or status macro&amp;nbsp;variable with values of 1 or 0 (true/ false) from the ratio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2019 14:32:11 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-04T14:32:11Z</dc:date>
    <item>
      <title>Evaluating a macro variable in a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548502#M8532</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I am creating a macro and the apply a condition. The macro variable is correctly calculated it is not well evaluated in the condition. See below a piece of the code and the log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Calculating the ratio E/U2;&lt;BR /&gt;data _null_;&lt;BR /&gt;set data;&lt;BR /&gt;call symputx ('E',a_var_e);&lt;BR /&gt;call symputx ('U2',a_var_u2);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let ratio = %sysevalf(&amp;amp;E/&amp;amp;U2);&lt;/P&gt;&lt;P&gt;%if &amp;amp;ratio &amp;gt; 0.0001 and &amp;amp;ratio &amp;lt;= 10 %then %put NOTE: Ratio in [0,10] ;&lt;BR /&gt;%else %put ERROR: Ratio not in [0,10], consider removing extreme observations;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log.&lt;/P&gt;&lt;P&gt;MLOGIC(ROOT_ESTIMATES): %LET (variable name is RATIO)&lt;BR /&gt;SYMBOLGEN: Macro variable E resolves to 0.1937225404&lt;BR /&gt;SYMBOLGEN: Macro variable U2 resolves to 0.0813614747&lt;BR /&gt;SYMBOLGEN: Macro variable RATIO resolves to 2.3810106824428&lt;BR /&gt;SYMBOLGEN: Macro variable RATIO resolves to 2.3810106824428&lt;BR /&gt;MLOGIC(ROOT_ESTIMATES): %IF condition &amp;amp;ratio &amp;gt; 0.0001 and &amp;amp;ratio &amp;lt;= 10 is FALSE&lt;BR /&gt;MLOGIC(ROOT_ESTIMATES): %PUT ERROR: Ratio not in [0,10], consider removing extreme observations&lt;BR /&gt;ERROR: Ratio not in [0,10], consider removing extreme observations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to solve this issue?&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548502#M8532</guid>
      <dc:creator>alexgonzalez</dc:creator>
      <dc:date>2019-04-04T14:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a macro variable in a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548504#M8533</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf(&amp;amp;ratio &amp;gt; 0.0001 and &amp;amp;ratio &amp;lt;= 10) %then %put NOTE: Ratio in [0,10] ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548504#M8533</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-04T14:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a macro variable in a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548505#M8534</link>
      <description>&lt;P&gt;You need to keep using %SYSEVALF() if you want to compare floating point values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let ratio = %&lt;FONT color="#FF0000"&gt;sysevalf&lt;/FONT&gt;(&amp;amp;E/&amp;amp;U2);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%if %&lt;FONT color="#FF0000"&gt;sysevalf&lt;/FONT&gt;(&amp;amp;ratio &amp;gt; 0.0001) and %&lt;FONT color="#FF0000"&gt;sysevalf&lt;/FONT&gt;(&amp;amp;ratio &amp;lt;= 10) %then %put NOTE: Ratio in [0,10] ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%else %put ERROR: Ratio not in [0,10], consider removing extreme observations;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548505#M8534</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-04T14:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a macro variable in a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548512#M8537</link>
      <description>&lt;P&gt;Thanks a lot Tom, it worked :).&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548512#M8537</guid>
      <dc:creator>alexgonzalez</dc:creator>
      <dc:date>2019-04-04T14:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a macro variable in a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548514#M8539</link>
      <description>&lt;P&gt;If the only purpose of the test of the value is place a note in the log then do it in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symputx ('E',a_var_e);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symputx ('U2',a_var_u2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if not (&amp;nbsp;0.000 1&amp;lt;&amp;nbsp;a_var_e / a_var_u2&amp;nbsp;le 10) then put "&amp;nbsp;NOTE: Ratio in [0,10] ";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else put "&amp;nbsp;ERROR: Ratio not in [0,10], consider removing extreme observations";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not using the macro variables E and U2 for anything else then don't create them and just use the PUT in the data _null_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have other uses for the comparison then you would be better off creating a flag or status macro&amp;nbsp;variable with values of 1 or 0 (true/ false) from the ratio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548514#M8539</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-04T14:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a macro variable in a condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548515#M8540</link>
      <description>&lt;P&gt;I didn't try this, but it's very similar to what Tom suggested. I'm assuming it'd work too.&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 14:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Evaluating-a-macro-variable-in-a-condition/m-p/548515#M8540</guid>
      <dc:creator>alexgonzalez</dc:creator>
      <dc:date>2019-04-04T14:32:32Z</dc:date>
    </item>
  </channel>
</rss>

