<?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 loop: variable list and while/until ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70934#M15329</link>
    <description>I don't know what you should avoid.  If you read the documentation carefully you will see that each comma separated specification can have it's own while/until clause.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
specification &lt;BR /&gt;
denotes an expression or a series of expressions in this form&lt;BR /&gt;
&lt;BR /&gt;
start &lt;TO stop=""&gt; &lt;BY increment=""&gt; &lt;WHILE&gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Very powerful!!&lt;/WHILE&gt;&lt;/BY&gt;&lt;/TO&gt;</description>
    <pubDate>Thu, 10 Feb 2011 02:08:20 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2011-02-10T02:08:20Z</dc:date>
    <item>
      <title>do loop: variable list and while/until ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70933#M15328</link>
      <description>Experts:&lt;BR /&gt;
Should we try to avoid using a variable list and the while / until condition together? It looks like the while / until does not kick in till the last variable value anyway. &lt;BR /&gt;
Thanks.&lt;BR /&gt;
data work.Test;&lt;BR /&gt;
	Amount=50;&lt;BR /&gt;
	do pay_time = 1,2,3,4 while (Amount LE 100);&lt;BR /&gt;
		Amount+ 50;&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=work.Test;&lt;BR /&gt;
run;&lt;BR /&gt;
data work.Test1;&lt;BR /&gt;
	Amount=50;&lt;BR /&gt;
	do pay_time = 1,2,3,4 until (Amount GE 100);&lt;BR /&gt;
		Amount+ 50;&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=work.Test1;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 10 Feb 2011 00:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70933#M15328</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2011-02-10T00:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: do loop: variable list and while/until ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70934#M15329</link>
      <description>I don't know what you should avoid.  If you read the documentation carefully you will see that each comma separated specification can have it's own while/until clause.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
specification &lt;BR /&gt;
denotes an expression or a series of expressions in this form&lt;BR /&gt;
&lt;BR /&gt;
start &lt;TO stop=""&gt; &lt;BY increment=""&gt; &lt;WHILE&gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Very powerful!!&lt;/WHILE&gt;&lt;/BY&gt;&lt;/TO&gt;</description>
      <pubDate>Thu, 10 Feb 2011 02:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70934#M15329</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-10T02:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: do loop: variable list and while/until ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70935#M15330</link>
      <description>The SAS log below, using a PUTLOG, not an OUTPUT, demonstrates clearly the SAS operational behavior with each:&lt;BR /&gt;
&lt;BR /&gt;
1    data work.Test;&lt;BR /&gt;
2    Amount=50;&lt;BR /&gt;
3    do pay_time = 1,2,3,4 while (Amount LE 100);&lt;BR /&gt;
4    Amount+ 50;&lt;BR /&gt;
5    putlog _all_;&lt;BR /&gt;
6    end;&lt;BR /&gt;
7    run;&lt;BR /&gt;
&lt;BR /&gt;
Amount=100 pay_time=1 _ERROR_=0 _N_=1&lt;BR /&gt;
Amount=150 pay_time=2 _ERROR_=0 _N_=1&lt;BR /&gt;
Amount=200 pay_time=3 _ERROR_=0 _N_=1&lt;BR /&gt;
NOTE: The data set WORK.TEST has 1 observations and 2 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
8    /*&lt;BR /&gt;
9    proc print data=work.Test;&lt;BR /&gt;
10   run;&lt;BR /&gt;
11   */&lt;BR /&gt;
12   data work.Test1;&lt;BR /&gt;
13   Amount=50;&lt;BR /&gt;
14   do pay_time = 1,2,3,4 until (Amount GE 100);&lt;BR /&gt;
15   Amount+ 50;&lt;BR /&gt;
16   putlog _all_;&lt;BR /&gt;
17   end;&lt;BR /&gt;
18   run;&lt;BR /&gt;
&lt;BR /&gt;
Amount=100 pay_time=1 _ERROR_=0 _N_=1&lt;BR /&gt;
Amount=150 pay_time=2 _ERROR_=0 _N_=1&lt;BR /&gt;
Amount=200 pay_time=3 _ERROR_=0 _N_=1&lt;BR /&gt;
Amount=250 pay_time=4 _ERROR_=0 _N_=1&lt;BR /&gt;
NOTE: The data set WORK.TEST1 has 1 observations and 2 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 10 Feb 2011 04:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70935#M15330</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-02-10T04:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: do loop: variable list and while/until ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70936#M15331</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;There is a difference between &lt;B&gt;do i=1 to 4 while...&lt;/B&gt; and &lt;B&gt;do i=1,2,3,4 while...&lt;/B&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;in the second one the expression is evaluated &lt;B&gt; only &lt;/B&gt; for the last item (i=4).&lt;BR /&gt;
&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt;in the first one the expression is evaluated at the beginning of each iteration. &lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;Consider the differences between these examples:&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data work.Test;&lt;BR /&gt;
Amount=50;&lt;BR /&gt;
do pay_time = 1,2,3,4 while (Amount LE 100);&lt;BR /&gt;
Amount+ 50;&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
data work.Test1;&lt;BR /&gt;
Amount=50;&lt;BR /&gt;
do pay_time = 1 to 4 while (Amount LE 100);&lt;BR /&gt;
Amount+ 50;&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=work.Test;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=work.Test1;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;HTH,&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Marius&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2011 08:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70936#M15331</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-10T08:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: do loop: variable list and while/until ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70937#M15332</link>
      <description>Thanks to all three of you!  I did not know we could combine While/Until with individual index variable values, multiple times ...in the do statement. Tested a few.  I have to agree with Data _null_ that it is powerful. A nice surprise!</description>
      <pubDate>Fri, 11 Feb 2011 05:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-variable-list-and-while-until/m-p/70937#M15332</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2011-02-11T05:07:06Z</dc:date>
    </item>
  </channel>
</rss>

