<?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: Need hints on %IF Statement in EG 5.1 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177296#M13592</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a good one for a puzzle book!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those dashes look like substraction to the macro processor.&amp;nbsp; There is an implied %EVAL() called by the %IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So&lt;/P&gt;&lt;P&gt;&amp;nbsp; %IF 2013-11= 2012-10&lt;/P&gt;&lt;P&gt;Becomes&lt;/P&gt;&lt;P&gt;&amp;nbsp; %IF (2013-11)=(2012-10)&lt;/P&gt;&lt;P&gt;i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if 2002=2002&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution is to add some macro quoting so that the dash isn't seen as a subsraction sign. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%macro check(dummy);
&amp;nbsp; %local cur_period strt_period1;
&amp;nbsp; %let cur_period=2013-11;
&amp;nbsp; %let strt_period1=2012-10;

&amp;nbsp; %put WITHOUT quoting ;
&amp;nbsp; %if &amp;amp;cur_period=&amp;amp;strt_period1 %then %put &amp;amp;cur_period EQUAL &amp;amp;strt_period1;
&amp;nbsp; %else %put &amp;amp;cur_period NOT EQUAL &amp;amp;strt_period1;

&amp;nbsp; %put WITH quoting: ;
&amp;nbsp; %if %superq(cur_period)=%superq(strt_period1) %then &amp;amp;cur_period EQUAL &amp;amp;strt_period1;
&amp;nbsp; %else %put &amp;amp;cur_period NOT EQUAL &amp;amp;strt_period1;
%mend check;

%check()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Feb 2014 20:39:10 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2014-02-17T20:39:10Z</dc:date>
    <item>
      <title>Need hints on %IF Statement in EG 5.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177294#M13590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi, can anyone help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this statment:&lt;/P&gt;&lt;P&gt;%IF (&amp;amp;cur_period = &amp;amp;srt_period1) .......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LOG are:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable CUR_PERIOD resolves to 2013-11&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable SRT_PERIOD1 resolves to 2012-10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MLOGIC(BUILD_STRING_2): %IF condition (&amp;amp;Cur_period = &amp;amp;srt_period1) is&lt;STRONG&gt; TRUE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;I think it should be FALSE. Any hints? Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177294#M13590</guid>
      <dc:creator>tlyang888</dc:creator>
      <dc:date>2014-02-17T20:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need hints on %IF Statement in EG 5.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177295#M13591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course it is true. 2013-11 is 2002 and 2012-10 is also 2002.&lt;/P&gt;&lt;P&gt;If you want the implied %eval() in your %IF to treat this formula's as strings then add quotes or something else.&lt;/P&gt;&lt;P&gt;%if &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;("&amp;amp;Cur_period" = "&amp;amp;srt_period1") ...&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;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%if &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;(X&amp;amp;Cur_period = X&amp;amp;srt_period1) ...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177295#M13591</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-17T20:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need hints on %IF Statement in EG 5.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177296#M13592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a good one for a puzzle book!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those dashes look like substraction to the macro processor.&amp;nbsp; There is an implied %EVAL() called by the %IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So&lt;/P&gt;&lt;P&gt;&amp;nbsp; %IF 2013-11= 2012-10&lt;/P&gt;&lt;P&gt;Becomes&lt;/P&gt;&lt;P&gt;&amp;nbsp; %IF (2013-11)=(2012-10)&lt;/P&gt;&lt;P&gt;i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if 2002=2002&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution is to add some macro quoting so that the dash isn't seen as a subsraction sign. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%macro check(dummy);
&amp;nbsp; %local cur_period strt_period1;
&amp;nbsp; %let cur_period=2013-11;
&amp;nbsp; %let strt_period1=2012-10;

&amp;nbsp; %put WITHOUT quoting ;
&amp;nbsp; %if &amp;amp;cur_period=&amp;amp;strt_period1 %then %put &amp;amp;cur_period EQUAL &amp;amp;strt_period1;
&amp;nbsp; %else %put &amp;amp;cur_period NOT EQUAL &amp;amp;strt_period1;

&amp;nbsp; %put WITH quoting: ;
&amp;nbsp; %if %superq(cur_period)=%superq(strt_period1) %then &amp;amp;cur_period EQUAL &amp;amp;strt_period1;
&amp;nbsp; %else %put &amp;amp;cur_period NOT EQUAL &amp;amp;strt_period1;
%mend check;

%check()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177296#M13592</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-02-17T20:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need hints on %IF Statement in EG 5.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177297#M13593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for those hints. It did answer my question. I did forget about some basics in macro. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177297#M13593</guid>
      <dc:creator>tlyang888</dc:creator>
      <dc:date>2014-02-17T20:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need hints on %IF Statement in EG 5.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177298#M13594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interestingly enough(??), the last variation won't work.&amp;nbsp; The hyphen still gets interpreted as subtraction.&amp;nbsp; However, now the presence of "X" causes an error because there is a character value within the arithmetic expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 00:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177298#M13594</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-18T00:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need hints on %IF Statement in EG 5.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177299#M13595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right. Either need to either quote it or macro quote it.&amp;nbsp; But interesting the presence of the non digit causes SAS to give an error that shows what is really happening.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #ff0000;"&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X2013-11X=X2011-10X&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 00:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-hints-on-IF-Statement-in-EG-5-1/m-p/177299#M13595</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-18T00:32:16Z</dc:date>
    </item>
  </channel>
</rss>

