<?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 condition returning FALSE for date condition which should return TRUE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541442#M149483</link>
    <description>Thanks a lot &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;. Makes sense.</description>
    <pubDate>Fri, 08 Mar 2019 15:53:13 GMT</pubDate>
    <dc:creator>bjlav90</dc:creator>
    <dc:date>2019-03-08T15:53:13Z</dc:date>
    <item>
      <title>%IF condition returning FALSE for date condition which should return TRUE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541433#M149478</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro variable like below which is triggered in my first program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let ddmmyyyy = "28Feb2019"d;	&lt;/PRE&gt;&lt;P&gt;On another program inside a macro i have a simple IF statement, see below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%if &amp;amp;ddmmyyyy. &amp;gt;= '31DEC2018'd %then %do;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect this to return a TRUE value however when i run the macro, the IF statement returns FALSE. See below for the extract from the LOG.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;MLOGIC(My_Macro): Beginning execution.&lt;BR /&gt;SYMBOLGEN: Macro variable DDMMYYYY resolves to "28Feb2019"d&lt;BR /&gt;MLOGIC(My_Macro): %IF condition &amp;amp;ddmmyyyy. &amp;gt;= '31DEC2018'd is FALSE&lt;BR /&gt;MLOGIC(My_Macro): Ending execution.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to return false if the days are less than 31 as it runs as expected for 31/12 and 31/01. Does anyone know why this is happening? I have a solution in place but would like to understand why this is happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS EG, version 9.2&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 15:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541433#M149478</guid>
      <dc:creator>bjlav90</dc:creator>
      <dc:date>2019-03-08T15:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: %IF condition returning FALSE for date condition which should return TRUE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541435#M149479</link>
      <description>&lt;P&gt;Macro language does not resolve dates into numeric values on SAS's date scale.&amp;nbsp; It makes comparisons based on the characters it finds, just as if you asked:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if abc &amp;gt; xyz %then ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to tell macro language to convert the date values to numeric dates, apply %sysevalf:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %sysevalf(&amp;amp;ddmmyyyy &amp;gt;= '31DEC2018'd) %then %do;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 15:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541435#M149479</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-08T15:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: %IF condition returning FALSE for date condition which should return TRUE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541440#M149482</link>
      <description>&lt;P&gt;You can't do this with macro variables. Macro variables are simply considered text, they have no other meaning — and are not interpreted as actual dates. So the test you are doing in the %IF is testing to see if the text string is greater than the other text string, and it is not greater, thus you get FALSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf(&amp;amp;ddmmyyyy. &amp;gt;= '31DEC2018'd) %then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 15:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541440#M149482</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-08T15:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: %IF condition returning FALSE for date condition which should return TRUE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541442#M149483</link>
      <description>Thanks a lot &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;. Makes sense.</description>
      <pubDate>Fri, 08 Mar 2019 15:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-condition-returning-FALSE-for-date-condition-which-should/m-p/541442#M149483</guid>
      <dc:creator>bjlav90</dc:creator>
      <dc:date>2019-03-08T15:53:13Z</dc:date>
    </item>
  </channel>
</rss>

