<?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: %IF %THEN not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206722#M38422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One principle to keep in mind is that this comparison is false:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if mean = "mean" %then %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro language does not require quotes.&amp;nbsp; Thus this compares four characters (on the left of the equal sign) to six characters (to the right of the equal sign).&amp;nbsp; In macro language, four characters can never equal six characters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Jun 2015 21:07:00 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-06-15T21:07:00Z</dc:date>
    <item>
      <title>%IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206719#M38419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using %IF %THEN and it works sometimes as expected. Sometimes it does not work as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code does not work when i put "mean" in quotes -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options minoperator mlogic;&lt;/P&gt;&lt;P&gt;%macro missing (method=); &lt;/P&gt;&lt;P&gt;%if %lowcase(&amp;amp;method.) = &lt;STRONG&gt;"mean"&lt;/STRONG&gt; or %lowcase(&amp;amp;method.) = &lt;STRONG&gt;"median"&lt;/STRONG&gt; %then %do; &lt;/P&gt;&lt;P&gt;%put type = "mean or median"; &lt;/P&gt;&lt;P&gt;%end; &lt;/P&gt;&lt;P&gt;%else %do; &lt;/P&gt;&lt;P&gt;%put type = "zero"; &lt;/P&gt;&lt;P&gt;%end; &lt;/P&gt;&lt;P&gt;%mend; &lt;/P&gt;&lt;P&gt;%missing (method=mean);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i replace the third line of code to : &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%if %lowcase(&amp;amp;method.) = &lt;STRONG&gt;mean&lt;/STRONG&gt; or %lowcase(&amp;amp;method.) = &lt;STRONG&gt;median&lt;/STRONG&gt; %then %do; , the code works.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 20:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206719#M38419</guid>
      <dc:creator>Ujjawal</dc:creator>
      <dc:date>2015-06-15T20:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206720#M38420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You likely have no reason to use a quoted-string and it's giving the SAS macro language compilation issues - review the SAS.COM support site DOC / reference material -- search argument:&lt;/P&gt;&lt;P&gt;quoted strings macro language site:sas.com&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott Barry&lt;BR /&gt;SBBWorks, Inc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 20:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206720#M38420</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2015-06-15T20:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206721#M38421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply. Sometimes the code works with quotes. I don't understand it. Could you please provide me the link? I searched on sas support site, didn't find the exact link.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 20:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206721#M38421</guid>
      <dc:creator>Ujjawal</dc:creator>
      <dc:date>2015-06-15T20:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206722#M38422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One principle to keep in mind is that this comparison is false:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if mean = "mean" %then %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro language does not require quotes.&amp;nbsp; Thus this compares four characters (on the left of the equal sign) to six characters (to the right of the equal sign).&amp;nbsp; In macro language, four characters can never equal six characters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 21:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206722#M38422</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-06-15T21:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206723#M38423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In regular SAS code you use quotes around literal strings to distinguish them from numeric literals, keywords or variable names. But &lt;SPAN style="font-size: 13.3333330154419px;"&gt;in macro logic quotes are not treated differently from other characters.&amp;nbsp; So it is the same as if you tried to test:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;%if %lowcase(&amp;amp;method) = XmethodX %then ....&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 01:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206723#M38423</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-06-16T01:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206724#M38424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To help you a little with wrapping your mind about this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%if %lowcase(&amp;amp;method.) = mean&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;works&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%if "%lowcase(&amp;amp;method.)" = "mean"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;will also work&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%if %lowcase(&amp;amp;method.) = "mean"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%if "%lowcase(&amp;amp;method.)" = mean&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;won't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Since the macro language only knows type char, no quotes are needed for constants.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;To further illustrate this, try:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%let macvar="Test";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%put "&amp;amp;macvar";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;and look at the log.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 05:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206724#M38424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-06-16T05:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %THEN not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206725#M38425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro language only has character datatype. There is no numeric datatype in Macro language. Hence quotations are not needed. If the value has quotes then you have to compare using the quotes else you dont need the quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 08:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-not-working/m-p/206725#M38425</guid>
      <dc:creator>bharathtuppad</dc:creator>
      <dc:date>2015-06-16T08:17:57Z</dc:date>
    </item>
  </channel>
</rss>

