<?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 compare variables with floating point values within a macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87217#M18614</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it will make a difference, as it did do in my last post when I showed I get the same result as you when I invoke the macro function without using an ampersand (&amp;amp;) before the second argument (b). The macro function will compare the value "32.5" (without the quotes) with the value "b" (without the quotes.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try changing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%calc_val(32.5, b)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%calc_val(32.5, &amp;amp;w)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Aug 2012 14:39:47 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2012-08-08T14:39:47Z</dc:date>
    <item>
      <title>How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87210#M18607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create this simple macro to compute an expression after doing a floating point number comparison ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro calc_val(x,y);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;x &amp;lt; &amp;amp;y %then &amp;lt;expression 1&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else &amp;lt;expression 2&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend calc_val;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* initiate macros */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let b = 23.6;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%calc_val(32.5, &amp;amp;b)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is running but it is not doing it properly.&lt;/P&gt;&lt;P&gt;In the above example, the SAS log file is saying&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;SYMBOLGEN: Macro variable X resolves to 32.5&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;SYMBOLGEN: Macro variable Y resolves to B&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;MLOGIC(CALC_VAL): %IF condition &amp;amp;x &amp;lt; &amp;amp;y is TRUE&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hence it is computing expression 1 instead it should have gone to compute expression 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where am I going wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87210#M18607</guid>
      <dc:creator>Bapan</dc:creator>
      <dc:date>2012-08-08T14:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87211#M18608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I ran your code and it looks fine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro calc_val(x,y);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;x &amp;lt; &amp;amp;y %then %put &amp;amp;x &amp;lt; &amp;amp;y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put &amp;amp;x ge &amp;amp;y;&lt;/P&gt;&lt;P&gt;%mend calc_val;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* initiate macros */&lt;/P&gt;&lt;P&gt;%let b = 23.6;&lt;/P&gt;&lt;P&gt;%calc_val(32.5, &amp;amp;b)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;log file:&lt;/P&gt;&lt;P&gt;17&amp;nbsp;&amp;nbsp; %macro calc_val(x,y);&lt;/P&gt;&lt;P&gt;18&lt;/P&gt;&lt;P&gt;19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;x &amp;lt; &amp;amp;y %then %put &amp;amp;x &amp;lt; &amp;amp;y;&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put &amp;amp;x ge &amp;amp;y;&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;23&amp;nbsp;&amp;nbsp; %mend calc_val;&lt;/P&gt;&lt;P&gt;24&lt;/P&gt;&lt;P&gt;25&lt;/P&gt;&lt;P&gt;26&lt;/P&gt;&lt;P&gt;27&amp;nbsp;&amp;nbsp; /* initiate macros */&lt;/P&gt;&lt;P&gt;28&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp; %let b = 23.6;&lt;/P&gt;&lt;P&gt;30&lt;/P&gt;&lt;P&gt;31&amp;nbsp;&amp;nbsp; %calc_val(32.5, &amp;amp;b)&lt;/P&gt;&lt;P&gt;32.5 ge 23.6&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87211#M18608</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-08T14:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87212#M18609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't reproduce your results.&amp;nbsp; Running your code with arguments you specified, I get expression 2&amp;nbsp; (i.e. &amp;amp;x &amp;lt; &amp;amp;y is NOT true), as expected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87212#M18609</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-08T14:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87213#M18610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try the following code based on yours it goes down the &lt;SPAN style="font-family: 'courier new', courier;"&gt;%else&lt;/SPAN&gt; branch and puts out "False".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro calc_val(x,y);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %if &amp;amp;x &amp;lt; &amp;amp;y %then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put True;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put False;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend calc_val;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;/* initiate macros */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let b = 23.6;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%calc_val(32.5, &amp;amp;b)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you get when you run the above?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87213#M18610</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-08-08T14:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87214#M18611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;options symbolgen mlogic;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see the following extract in the log:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable B resolves to 23.6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; Parameter X has value 32.5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; Parameter Y has value 23.6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable X resolves to 32.5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable Y resolves to 23.6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; %IF condition &amp;amp;x &amp;lt; &amp;amp;y is FALSE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; %PUT False&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way I can reproduce your result is by invoking the macro function without using the ampersand (&amp;amp;) before the second argument (b):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%calc_val(32.5, b)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which gives:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; Parameter X has value 32.5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; Parameter Y has value b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable X resolves to 32.5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable Y resolves to b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MLOGIC(CALC_VAL):&amp;nbsp; %IF condition &amp;amp;x &amp;lt; &amp;amp;y is TRUE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87214#M18611</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-08-08T14:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87215#M18612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, I am still getting an issue. Will it make a difference if the value of b is actually getting calcaulted within a data step of another macro.&lt;/P&gt;&lt;P&gt;I am also calling the the original macro from within this data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, effectively I have ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro calc_val(x,y);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;x &amp;lt; &amp;amp;y %then &amp;lt;expression 1&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else &amp;lt;expression 2&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend calc_val;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro mac_1(w);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data qwer;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = &amp;amp;w;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %calc_val(32.5, b)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend mac_1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* initiate macros */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let c = 23.5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mac_1(&amp;amp;c)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;???&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87215#M18612</guid>
      <dc:creator>Bapan</dc:creator>
      <dc:date>2012-08-08T14:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87216#M18613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue you are looking at is that macro language is making a character comparison, not a numeric comparison.&amp;nbsp; Decimal points are not interpreted as numbers by macro language.&amp;nbsp; So if you changed your example to use 203.5 instead of 23.5, you would get the unexpected results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution is easy.&amp;nbsp; Macro language contains a function that supports floating point arithmetic.&amp;nbsp; Change your comparison to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if %sysevalf ( &amp;amp;x &amp;lt; &amp;amp;y ) %then %put True;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That should take care of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87216#M18613</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-08T14:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87217#M18614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it will make a difference, as it did do in my last post when I showed I get the same result as you when I invoke the macro function without using an ampersand (&amp;amp;) before the second argument (b). The macro function will compare the value "32.5" (without the quotes) with the value "b" (without the quotes.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try changing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%calc_val(32.5, b)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%calc_val(32.5, &amp;amp;w)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87217#M18614</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-08-08T14:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87218#M18615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amir, Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It does work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this mean I need to use &amp;amp;w only?&lt;/P&gt;&lt;P&gt;Why is SAS not able to pass on the value stored in variable 'b' to the next macro?&lt;/P&gt;&lt;P&gt;Do you know of any other work around?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87218#M18615</guid>
      <dc:creator>Bapan</dc:creator>
      <dc:date>2012-08-08T14:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87219#M18616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you insist not using &amp;amp;w then changing&lt;/P&gt;&lt;P&gt;b=&amp;amp;w&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;%let b=&amp;amp;w;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87219#M18616</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-08T14:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87220#M18617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linlin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't use that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Recall that 'b=&amp;amp;w' statement is placed within the data step of the macro.&lt;/P&gt;&lt;P&gt;Essentially b will become a variable for the data table qwer !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87220#M18617</guid>
      <dc:creator>Bapan</dc:creator>
      <dc:date>2012-08-08T14:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87221#M18618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Does this mean I need to use &amp;amp;w only?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;That is all you need to call the macro function.&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;EM style=": ; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Why is SAS not able to pass on the value stored in variable 'b' to the next macro?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Because the macros are processed first then data steps are processed afterwards.&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;EM style=": ; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Do you know of any other work around?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;As SAS is working as designed, I would not consider a workaround is necessary.&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;&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;You can still assign the value &amp;amp;w to b if you need to use b as a data step variable, but you'll still need to use &amp;amp;w in the macro function call.&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;&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;&lt;STRONG&gt;NB&lt;/STRONG&gt;. Please also follow Astounding's recommendation about the use of &lt;SPAN style="font-family: 'courier new', courier;"&gt;%sysevalf()&lt;/SPAN&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;&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;Regards,&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;Amir.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 14:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87221#M18618</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-08-08T14:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare variables with floating point values within a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87222#M18619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know why you would not use &amp;amp;W as the parameter in your macro call, since its value is unchanged for your entire data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you may be looking for the RESOLVE function, which provides a means to delay resolution of a macro call until data step execution - i..e it's a means of having the data in a given record influence what the macro returns.&amp;nbsp; As in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; t(arg);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; %if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &amp;amp;arg=&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;%then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; %else&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;%mend &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;t;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;data have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; a=&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; b=a*resolve(cats('%t(',a,')'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; put a= b=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;But this will probably generate a significant performance hit, which you can test by multiplying data set HAVE to, say 100,000 observations.&amp;nbsp; Then run the above data _null_ step (take out the put statement), and compare its speed to this data _null_ step:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; if a=1 then b=a*%t(1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; else b=a*%t(2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 15:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-variables-with-floating-point-values-within-a/m-p/87222#M18619</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-08T15:31:18Z</dc:date>
    </item>
  </channel>
</rss>

