<?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 Do Loop Until Criteria is Met? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144815#M38452</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello I have an array of procedures of up to 20 cases.&amp;nbsp; I want to loop through looking for specific codes and when found then I don't want to continue looping through.&amp;nbsp; The reason is because the first occurrence of the matching procedure is the one I want to use and there is a possibility another code could match it's not the one I want to evaluate. if ca_dx eq "N" and age&amp;gt;=18 and Adm= "L" then do i = 1 to 20 until (proccde&lt;I&gt; = ''); if ooh&lt;I&gt; ne "Y" and substr(proccde&lt;I&gt;,1,5) in ("1SY80") and substr(proccde&lt;I&gt;,6,2) ne "BA" and atribloc&lt;I&gt; Not In ("0","B") and atribstat&lt;I&gt; ne "A" then ventral_px=1; end; But really for the above I want it to stop at the first procedure that is "1SY80"....is there any way to do this?&amp;nbsp; Thanks.&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Mar 2014 20:29:45 GMT</pubDate>
    <dc:creator>shellp55</dc:creator>
    <dc:date>2014-03-14T20:29:45Z</dc:date>
    <item>
      <title>Do Loop Until Criteria is Met?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144815#M38452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello I have an array of procedures of up to 20 cases.&amp;nbsp; I want to loop through looking for specific codes and when found then I don't want to continue looping through.&amp;nbsp; The reason is because the first occurrence of the matching procedure is the one I want to use and there is a possibility another code could match it's not the one I want to evaluate. if ca_dx eq "N" and age&amp;gt;=18 and Adm= "L" then do i = 1 to 20 until (proccde&lt;I&gt; = ''); if ooh&lt;I&gt; ne "Y" and substr(proccde&lt;I&gt;,1,5) in ("1SY80") and substr(proccde&lt;I&gt;,6,2) ne "BA" and atribloc&lt;I&gt; Not In ("0","B") and atribstat&lt;I&gt; ne "A" then ventral_px=1; end; But really for the above I want it to stop at the first procedure that is "1SY80"....is there any way to do this?&amp;nbsp; Thanks.&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 20:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144815#M38452</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2014-03-14T20:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Until Criteria is Met?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144816#M38453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, by a few ways.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In your do loop add another condition which is a flag and when the flag is set it stops. Set the flag using a if/then/do when the first occurance is found.&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do while (original condition AND flag =0); *Watch your and/ifs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if proccde&lt;I&gt;="ABC" then do;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;flag=1;&lt;/P&gt;&lt;P&gt;index=i;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Change the way you search for the instance of procedure code using the whichc/whichn function instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 20:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144816#M38453</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-14T20:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Until Criteria is Met?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144817#M38454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza Thanks very much.&amp;nbsp; Sorry but I'm not understanding the first section.&amp;nbsp; So using my code, would it be:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;do while cco eq "N" and age&amp;gt;=18 and Adm= "L" and flag=0;&lt;/P&gt;&lt;P&gt;if ooh&lt;I&gt; ne "Y" and substr(proccde&lt;I&gt;,1,5) in ("1NT86") and substr(proccde&lt;I&gt;,6,2) ne "BA" and Type="DS" and atribstat&lt;I&gt; ne "A" then do;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;flag=1;&lt;/P&gt;&lt;P&gt;anoA_px=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many others and right now they are all within the do and end piece so is it still okay that I do that I can add the next one after the last line above?&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 20:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144817#M38454</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2014-03-14T20:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Until Criteria is Met?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144818#M38455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not 100% sure, depends on your logic &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you'll have to test it to see.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially the idea is correct, except I think you do have to have the while condition in brackets, and make sure your end statements line up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 20:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144818#M38455</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-14T20:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop Until Criteria is Met?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144819#M38456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could just use the LEAVE statement to exit the loop.&lt;/P&gt;&lt;P&gt;For example try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 by 1 until (i&amp;gt;100) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i=10 then leave ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put i=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 22:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-Loop-Until-Criteria-is-Met/m-p/144819#M38456</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-14T22:07:28Z</dc:date>
    </item>
  </channel>
</rss>

