<?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: Macro logic for a value between 2 numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82829#M17873</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right since bwgt is not gt 0 and lt 50.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2013 13:52:39 GMT</pubDate>
    <dc:creator>kmorrowvt</dc:creator>
    <dc:date>2013-03-20T13:52:39Z</dc:date>
    <item>
      <title>Macro logic for a value between 2 numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82826#M17870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to figure out why this macro logic is working in this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let bwgt=50;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if 0 lt &amp;amp;bwgt and &amp;amp;bwgt lt 50 %then %put test1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if 0 lt &amp;amp;bwgt lt 50 %then %put test2;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This returns test2.&lt;/P&gt;&lt;P&gt;Why is it returning this when bwgt=50?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously I can just write my code with an "and" and get around this issue, but I'm curious as to why this is happening&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kate&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 13:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82826#M17870</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2013-03-20T13:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro logic for a value between 2 numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82827#M17871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unlike a DATA step, macro language does not process this as two separate comparisons:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0 lt &amp;amp;bwgt lt 50&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead, macro language processes from left to right, as if you had coded:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(0 lt &amp;amp;bwgt) lt 50&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like a DATA step, macro language replaces true comparisons with a 0 and false comparisons with a 1.&amp;nbsp; Since both 0 and 1 are less than 50, you will always get "test2" for any numeric value of &amp;amp;bwgt even if it's 55.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good job on prodding, exploring, and asking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 13:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82827#M17871</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-03-20T13:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro logic for a value between 2 numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82828#M17872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't fins any references in documentation to that you can use the same between and logic with %if (as you can with if in the data step). But I can't explain why this is happening. You wanted this test to come up as false, right?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 13:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82828#M17872</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-03-20T13:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro logic for a value between 2 numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82829#M17873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right since bwgt is not gt 0 and lt 50.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 13:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-logic-for-a-value-between-2-numbers/m-p/82829#M17873</guid>
      <dc:creator>kmorrowvt</dc:creator>
      <dc:date>2013-03-20T13:52:39Z</dc:date>
    </item>
  </channel>
</rss>

