<?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: %do %until loop resolves even though condition is false in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50544#M10560</link>
    <description>The first %DO statement shown in the original post has incorrect syntax and would generate an error.  The %DO %UNTIL(...)  logic inside the parentheses must be enclosed in parentheses itself and you must use %SYSEVALF(&lt;EXPRESSION&gt;) correctly.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
sysevalf documentation site:sas.com&lt;/EXPRESSION&gt;</description>
    <pubDate>Thu, 15 Jul 2010 17:43:57 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2010-07-15T17:43:57Z</dc:date>
    <item>
      <title>%do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50536#M10552</link>
      <description>The following loop ends after one iteration even though Max_V1&amp;gt;5. However the code works perfectly if I use a fraction (say 0.5) instead of a number above 1 (5 in my current code)&lt;BR /&gt;
&lt;BR /&gt;
%do %until (&amp;amp;Max_V1.) le 5);&lt;BR /&gt;
    &lt;BR /&gt;
        a few more lines of code goes here........then ......&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL NOPRINT;&lt;BR /&gt;
SELECT VarianceInflation_Max INTO: Max_V1 &lt;BR /&gt;
FROM Sum_stat;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
	    &lt;BR /&gt;
%if &amp;amp;Max_V1. le 5  %then %goto leave;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
Select Variable INTO: Drop_Var  &lt;BR /&gt;
from Spdework.varlist 	where VarianceInflation = (select max(Varia)  as  MV&lt;BR /&gt;
from varlist);&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
		&lt;BR /&gt;
		&lt;BR /&gt;
		&lt;BR /&gt;
proc sql;&lt;BR /&gt;
Select Variable INTO: L_F_Vars SEPARATED by ' ' &lt;BR /&gt;
From Varlist&lt;BR /&gt;
Where Variable &amp;lt;&amp;gt; "&amp;amp;Drop_Var.";&lt;BR /&gt;
quit;&lt;BR /&gt;
		  &lt;BR /&gt;
      &lt;BR /&gt;
              &lt;BR /&gt;
%END;&lt;BR /&gt;
  %leave:&lt;BR /&gt;
%mend auto_vif;</description>
      <pubDate>Thu, 15 Jul 2010 13:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50536#M10552</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2010-07-15T13:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50537#M10553</link>
      <description>do until is evaluated at the end of the loop and do while is evaluated at the top of the loop.</description>
      <pubDate>Thu, 15 Jul 2010 13:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50537#M10553</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-07-15T13:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50538#M10554</link>
      <description>Thanks for yor reply. I am nit sure why SAS log displays the following message...&lt;BR /&gt;
SYMBOLGEN:  Macro variable MAX_V1 resolves to 49.809566165&lt;BR /&gt;
MLOGIC(AUTO_VIF):  %IF condition %sysevalf(&amp;amp;Max_V1) le 5 is TRUE&lt;BR /&gt;
MLOGIC(AUTO_VIF):  %GOTO LEAVE (label resolves to LEAVE).&lt;BR /&gt;
MLOGIC(AUTO_VIF):  Ending execution.</description>
      <pubDate>Thu, 15 Jul 2010 13:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50538#M10554</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2010-07-15T13:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50539#M10555</link>
      <description>Did you interrogate the value of SAS variable VarianceInflation_Max in file WORK.Sum_stat?  Note your SAS PROC SQL uses this variable to assign the macro variable.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 15 Jul 2010 14:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50539#M10555</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-15T14:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50540#M10556</link>
      <description>Yes and it has the same value of 49. Thanks.</description>
      <pubDate>Thu, 15 Jul 2010 14:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50540#M10556</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2010-07-15T14:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50541#M10557</link>
      <description>That's the value you see (SAS output format), not necessarily the internal value.  Suggest you might use the BEST.  format to display the SAS variable - also how is the SAS variable calculated/computed?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 15 Jul 2010 15:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50541#M10557</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-15T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50542#M10558</link>
      <description>&amp;gt; displays the following message...&lt;BR /&gt;
&amp;gt; SYMBOLGEN:  Macro variable MAX_V1 resolves to 49.809566165&lt;BR /&gt;
&amp;gt; MLOGIC(AUTO_VIF):  %IF condition %sysevalf(&amp;amp;Max_V1) le 5 is TRUE&lt;BR /&gt;
&lt;BR /&gt;
that TRUE above implies a string comparison of %sysevalf(&amp;amp;Max_V1) and the 5. &lt;BR /&gt;
Perhaps the evaluation of %sysevalf(&amp;amp;Max_V1) needs to be done before the compare in the %do statement</description>
      <pubDate>Thu, 15 Jul 2010 15:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50542#M10558</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-07-15T15:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50543#M10559</link>
      <description>Yes I tried that but it does not work. THe loop works fine if I use a %do %unitl (&amp;amp;Max_V1 lt .9)   i.e. I use any number under 1 on the R.H.S. of the inequality sign.</description>
      <pubDate>Thu, 15 Jul 2010 17:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50543#M10559</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2010-07-15T17:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50544#M10560</link>
      <description>The first %DO statement shown in the original post has incorrect syntax and would generate an error.  The %DO %UNTIL(...)  logic inside the parentheses must be enclosed in parentheses itself and you must use %SYSEVALF(&lt;EXPRESSION&gt;) correctly.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
sysevalf documentation site:sas.com&lt;/EXPRESSION&gt;</description>
      <pubDate>Thu, 15 Jul 2010 17:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50544#M10560</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-15T17:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50545#M10561</link>
      <description>Numeric expressions are evaluated with a %EVAL (which only works with integers).  If either side of your expression resolves to a non-integer, and anything with a decimal point including 1. is a non-integer, the comparison becomes alphabetic rather than numeric.  Using %SYSEVALF as Scott suggests forces a numeric comparison on non-integers.</description>
      <pubDate>Thu, 15 Jul 2010 17:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50545#M10561</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-07-15T17:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50546#M10562</link>
      <description>if that is the case, then how does the code work whenI I use a fraction (say .1) on the RHS of the inequality. Thanks for your help.</description>
      <pubDate>Thu, 15 Jul 2010 18:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50546#M10562</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2010-07-15T18:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50547#M10563</link>
      <description>Consider the following snippet from my LOG:&lt;BR /&gt;
[pre]&lt;BR /&gt;
87   %macro test;&lt;BR /&gt;
88   %let v=49.5;&lt;BR /&gt;
89   %if &amp;amp;v lt 5 %then %put &amp;amp;v is less than 5;&lt;BR /&gt;
90   %if &amp;amp;v gt .5 %then %put &amp;amp;v is GT than .5;&lt;BR /&gt;
91   %if %sysevalf(&amp;amp;v gt 5) %then %put &amp;amp;v is GT than 5;&lt;BR /&gt;
92   %mend test;&lt;BR /&gt;
93   %test&lt;BR /&gt;
49.5 is less than 5&lt;BR /&gt;
49.5 is GT than .5&lt;BR /&gt;
49.5 is GT than 5&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Although the second %IF appears to evaluate correctly (numerically) it is actually doing an alphabetic comparison (decimal points sort before numbers alphabetically on my OS - windows).&lt;BR /&gt;
Only the third expression is actually giving correct numeric results.&lt;BR /&gt;
&lt;BR /&gt;
The key is to remember that for expressions to be evaluated numerically in the macro language they must be integer or alternatively we take charge with the %SYSEVALF function.&lt;BR /&gt;
Art</description>
      <pubDate>Thu, 15 Jul 2010 19:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50547#M10563</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-07-15T19:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: %do %until loop resolves even though condition is false</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50548#M10564</link>
      <description>Thanks for your reply. I was able to fix the issue with the sysevalf condition in the appropriate place.</description>
      <pubDate>Thu, 15 Jul 2010 19:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-until-loop-resolves-even-though-condition-is-false/m-p/50548#M10564</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2010-07-15T19:26:27Z</dc:date>
    </item>
  </channel>
</rss>

