Date: Sun, 18 Jul 2010 19:12:37 -0500 Kevin Myers "SAS(r) Discussion" Kevin Myers Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition) To: Joe Matise text/plain; charset="iso-8859-1"

Of course, that makes sense. Therefore this does something similar to what I mistakenly anticipated previously: data _null_;

do n=1 while(n>2), 2 while(n=2), 3 while(n<2), 10 to 1 by -1 while(n>3);

put n=;

end;

run;

(Prints 2, 10, 9, 8, 7, 6, 5, 4)

----- Original Message ----- From: Joe Matise To: Kevin Myers Cc: SAS-L@listserv.uga.edu Sent: Sunday, July 18, 2010 19:00 Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition)

I think it's obvious what it does. Just looking at the last part: do i = 1 to 10 while i > 3;

It starts with 1. It sees that 1 is not > 3. It terminates that portion of the loop.

That's what it should do, in my opinion. DO WHILE means do things until you first find a false statement then end.

-Joe

On Sun, Jul 18, 2010 at 6:54 PM, Kevin Myers <KevinMyers@austin.rr.com> wrote:

The previous example (final while expression was n<8) printed: 2, 1, 2, 3, 4, 5, 6, 7

So by only changing the final while expression to n>3, I would have expected: 2, 4, 5, 6, 7, 8, 9, 10

----- Original Message ----- From: "Data _null_;" <iebupdte@GMAIL.COM> To: <SAS-L@LISTSERV.UGA.EDU>

Sent: Sunday, July 18, 2010 18:34 Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition)

What do you thing it should do?

2 while(n=2) seems the only one that is ever true.

On 7/18/10, Kevin Myers <KevinMyers@austin.rr.com> wrote:

In fact, neither does this: data _null_;

do n=1 while(n>2), 2 while(n=2), 3 while(n<2), 1 to 10 while(n>3);

put n=;

end;

run;

----- Original Message ----- From: Kevin Myers To: toby dunn ; sas-l@listserv.uga.edu ; Paul Dorfman Sent: Sunday, July 18, 2010 18:14 Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition)

Interesting, and buggy...

This works as anticipated: data _null_;

do n=1 while(n>2), 2 while(n=2), 3 while(n<2), 1 to 10 while(n<8);

put n=;

end;

run;

But this doesn't: data _null_;

do n=1 while(n>2), 2 while(n=2), 3 while(n<2), 1 to 10 while(mod(n,3)=0);

put n=;

end;

run;

----- Original Message ----- From: Kevin Myers To: toby dunn ; sas-l@listserv.uga.edu ; Paul Dorfman Sent: Sunday, July 18, 2010 18:03 Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition)

Perhaps this example better illustrates the behavior:

6 data _null_;

7 do n=1 while(n>2), 2 while(n=2), 3 while(n<2);

8 put n=;

9 end;

10 run;

n=2

NOTE: DATA statement used:

real time 0.00 seconds

cpu time 0.00 seconds

----- Original Message ----- From: toby dunn To: kevinmyers@austin.rr.com ; sas-l@listserv.uga.edu ; Paul Dorfman Sent: Sunday, July 18, 2010 17:54 Subject: RE: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition)

Paul,

A little digging and I cam across this in the docs:

A WHILE or UNTIL specification affects only the last item in the clause in which it is located.

So Do I = 1 , 2 , 3 Until( I = 2 ) , would mean it is only checked for the 3 and not the 1 or 2. Which means using the a hybrid Do iterative list and and a While|Until is pretty much worthless hunk of shit code. Which after a little testing seems to hold true.

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Sun, 18 Jul 2010 17:03:27 -0500 > From: KevinMyers@AUSTIN.RR.COM > Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and UNTIL condition) > To: SAS-L@LISTSERV.UGA.EDU > > Toby, I think you may be missing the point on this one. It is performing as > designed/intended. The While/Until clause only applies to the individual > comma delimited portion of the DO loop indexes of which it is a part. Each > comma delimited portion of the DO loop index is treated in essence as if it > is controlling completely separate set of iterations for the DO loop. You > iterate over and exit from the first command delimited index clause before > moving on to the next comma delimited portion. > > s/KAM > > > ----- Original Message ----- > From: "toby dunn" <tobydunn@HOTMAIL.COM> > To: <SAS-L@LISTSERV.UGA.EDU> > Sent: Sunday, July 18, 2010 16:54 > Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and > UNTIL condition) > > > Good point Data _Null_, I hadnt thought to add a value greater than 2 as the > first element. Seems the bug still holds true > > Toby Dunn > > "Don't bail. The best gold is at the bottom of barrels of crap." > Randy Pausch > > "Be prepared. Luck is where preparation meets opportunity." > Randy Pausch > > > > > > Date: Sun, 18 Jul 2010 16:26:31 -0500 > > Subject: Re: Bona fide DO-loop bug (was: Re: Combining iterative DO and > > UNTIL condition) > > From: iebupdte@gmail.com > > To: tobydunn@hotmail.com > > CC: SAS-L@listserv.uga.edu > > > > On 7/18/10, toby dunn <tobydunn@hotmail.com> wrote: > > > Especially in light of the fact that this does work as expected: > > > data _null_ ; > > > do x = 1, 2, 3 While (x < 3) ; > > > put x= ; > > > end ; > > > Run ; > > > > I believe your example is flawed. > > > > 120 data _null_; > > 121 do x = 4, 1, 2, 3 While (x < 3) ; > > 122 put x=; > > 123 end; > > 124 run; > > > > x=4 > > x=1 > > x=2 > > > > You/we need to understand what the COMMA means and what syntax > > elements it "delimites". > > _________________________________________________________________ > Hotmail is redefining busy with tools for the New Busy. Get more from your > inbox. > http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2=

-------------------------------------------------------------------------- Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.

Back to: Top of message | Previous page | Main SAS-L page