<?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 i=1 TO z UNTIL (x=1) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606336#M176058</link>
    <description>&lt;P&gt;Possible but likely not easily . IF you want to break out of a look that would normally execute Z times but a condition inside the loop sets a value such that you would like to end the loop the instruction is LEAVE. The dummy code for the loop would look like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;do I = 1 to z;
   &amp;lt;some statements&amp;gt;
   if x=1 then leave;
   &amp;lt;other statements to execute if not leaving the loop&amp;gt;

end;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Nov 2019 23:16:18 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-11-21T23:16:18Z</dc:date>
    <item>
      <title>DO i=1 TO z UNTIL (x=1)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606326#M176055</link>
      <description>&lt;P&gt;My subject line gives the basic premise of my issue. Forgive me if this is elementary, but I can't find SAS documentation outlining it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, can I use a DO i=1 to Z loop with an UNTIL conditional statement? I'm also wondering if I can use multiple different UNTIL conditions as a stopping point (so whether I can&amp;nbsp;and how I can use an OR operator in the UNTIL conditional).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I figured this would be possible, but when I try to process my macro I get the following:&lt;/P&gt;&lt;P&gt;ERROR 68-185: The function UNTIL is unknown, or cannot be accessed.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 22:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606326#M176055</guid>
      <dc:creator>solfay243</dc:creator>
      <dc:date>2019-11-21T22:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: DO i=1 TO z UNTIL (x=1)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606336#M176058</link>
      <description>&lt;P&gt;Possible but likely not easily . IF you want to break out of a look that would normally execute Z times but a condition inside the loop sets a value such that you would like to end the loop the instruction is LEAVE. The dummy code for the loop would look like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;do I = 1 to z;
   &amp;lt;some statements&amp;gt;
   if x=1 then leave;
   &amp;lt;other statements to execute if not leaving the loop&amp;gt;

end;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 23:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606336#M176058</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-21T23:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: DO i=1 TO z UNTIL (x=1)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606340#M176059</link>
      <description>&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wasn't aware of the "LEAVE" statement and hadn't read that anywhere before!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 23:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606340#M176059</guid>
      <dc:creator>solfay243</dc:creator>
      <dc:date>2019-11-21T23:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: DO i=1 TO z UNTIL (x=1)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606418#M176096</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show the code you used ? The following code works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
z=10;
x=5;
do i=1 to z until(x=1);
x+(-1);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2019 10:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606418#M176096</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-11-22T10:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: DO i=1 TO z UNTIL (x=1)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606503#M176123</link>
      <description>&lt;P&gt;You cannot have multiple UNTIL() (or have both an UNTIL() and a WHILE()).&lt;/P&gt;
&lt;P&gt;Note you can easily test such things yourself by just generating the code yourself BEFORE trying to create a macro to generate the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the condition in the UNTIL () could be as complex as you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to z until(x=1 or y&amp;lt;0 or (w1=3 and w2=4) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are comfortable debugging&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Spaghetti_code" target="_self"&gt;spaghetti code&lt;/A&gt;&amp;nbsp;you could use the LEAVE statement to exit the loop from the middle..&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 16:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-i-1-TO-z-UNTIL-x-1/m-p/606503#M176123</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-22T16:09:44Z</dc:date>
    </item>
  </channel>
</rss>

