<?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 help with macro problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105336#M291528</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro v3(datain,flaga,flagb);&lt;BR /&gt;%if &amp;amp;flaga = LT %then&lt;BR /&gt;%do;&lt;BR /&gt;%put &amp;amp;flaga;&lt;BR /&gt;%end;&lt;BR /&gt;%else&lt;BR /&gt;%do;&lt;BR /&gt;%put &amp;amp;flagb;&lt;BR /&gt;%end;&lt;BR /&gt;%mend v3;&lt;/P&gt;&lt;P&gt;%v3(aa,LT,error);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always get error instead of LT in this case. Why?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Aug 2012 21:27:37 GMT</pubDate>
    <dc:creator>KCKC</dc:creator>
    <dc:date>2012-08-27T21:27:37Z</dc:date>
    <item>
      <title>help with macro problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105336#M291528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro v3(datain,flaga,flagb);&lt;BR /&gt;%if &amp;amp;flaga = LT %then&lt;BR /&gt;%do;&lt;BR /&gt;%put &amp;amp;flaga;&lt;BR /&gt;%end;&lt;BR /&gt;%else&lt;BR /&gt;%do;&lt;BR /&gt;%put &amp;amp;flagb;&lt;BR /&gt;%end;&lt;BR /&gt;%mend v3;&lt;/P&gt;&lt;P&gt;%v3(aa,LT,error);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always get error instead of LT in this case. Why?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2012 21:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105336#M291528</guid>
      <dc:creator>KCKC</dc:creator>
      <dc:date>2012-08-27T21:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: help with macro problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105337#M291529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try it with quotes.&amp;nbsp; i.e.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro v3(datain,flaga,flagb);&lt;/P&gt;&lt;P&gt;%if "&amp;amp;flaga" = "LT" %then&lt;/P&gt;&lt;P&gt;%do;&lt;/P&gt;&lt;P&gt;%put &amp;amp;flaga;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else&lt;/P&gt;&lt;P&gt;%do;&lt;/P&gt;&lt;P&gt;%put &amp;amp;flagb;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend v3;&lt;/P&gt;&lt;P&gt;%v3(aa,LT,error)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and, since you're probably going to ask "why?", I think it is because LT is being considered an operator.&amp;nbsp; I'd call this a bug, but I'm sure that someone else will say it is a feature.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will get the desired results by not using an operator as the value.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro v3(datain,flaga,flagb);&lt;/P&gt;&lt;P&gt;%if &amp;amp;flaga. = TT %then&lt;/P&gt;&lt;P&gt;%do;&lt;/P&gt;&lt;P&gt;%put &amp;amp;flaga;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else&lt;/P&gt;&lt;P&gt;%do;&lt;/P&gt;&lt;P&gt;%put &amp;amp;flagb;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend v3;&lt;/P&gt;&lt;P&gt;%v3(aa,TT,error)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2012 21:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105337#M291529</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-27T21:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: help with macro problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105338#M291530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that's right.&amp;nbsp; Within a %IF condition, LT = "less than".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro language makes comparisons from left to right.&amp;nbsp; The first comparison within:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;flaga = LT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;compares &amp;amp;flaga to the null value before "LT" to see if they are equal.&amp;nbsp; Macro language finds that they are not equal, so the comparison is false.&amp;nbsp; False comparisons generate a 0, while true comaprisons generate a 1.&amp;nbsp; So the second comparison compares 0 to see if it is less than the null value following "LT".&amp;nbsp; That comparison is also false, so the %ELSE statement kicks in.&amp;nbsp; To verify that this is happening, try using the same parameters, but modifying the %IF statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;flaga = LT 2 %then %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regardless of the value of &amp;amp;flaga, this comparison should always be true.&amp;nbsp; Macro language will always be comparing either (0 LT 2) or (1 LT 2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps rather than confuses!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2012 00:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105338#M291530</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-28T00:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: help with macro problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105339#M291531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Folks, thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2012 02:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-macro-problem/m-p/105339#M291531</guid>
      <dc:creator>KCKC</dc:creator>
      <dc:date>2012-08-28T02:10:30Z</dc:date>
    </item>
  </channel>
</rss>

