LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 18 Jul 2000 14:13:19 -0600
Reply-To:     Kenneth Moody <KennethMoody@FIRSTHEALTH.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Kenneth Moody <KennethMoody@FIRSTHEALTH.COM>
Subject:      Re: SAS: Iterative do loops with until statement
Content-Type: text/plain; charset=us-ascii

The answer to your question (a) is in the definition of the iterative DO. In your first example you've used one "specification", in the second example you've used three "specifications". In the second example, the "until (flag=1)" is part of the third specification and doesn't get executed until the bottom of the loop when n is three.

You can mimic the behavior of the first example by explicitly coding the test at the bottom of the loop: do n= ...;

if flag=1 then leave; end;

Ken Moody First Health, Metrics Department Voice: 916-374-3924 EMail: KennethMoody@firsthealth.com

>>> "Hudson, Spencer" <shudson@VIROPHARMA.COM> 07/18 12:25 PM >>> Sometimes when you're not looking, the simple stuff comes and bites. In the following two steps, the first stops at n = 6, but the second continues to n=3. Can anyone tell me (a) why, and (b) can I mimic the first do loop using the syntax of the second. I ask this because my real specification list does not have even increments, so I cannot use the first syntax.

Thanks, Spencer Hudson

308 309 data _null_; 310 flag = 0; 311 do n = 9 to 3 by -3 until (flag=1); 312 if 7 >= n then flag = 1; 313 put n= flag=; 314 end; 315 put n= flag=; 316 run;

N=9 FLAG=0 N=6 FLAG=1 N=6 FLAG=1 NOTE: The DATA statement used 0.01 seconds.

317 318 data _null_; 319 flag = 0; 320 do n = 9, 6, 3 until (flag=1); 321 if 7 >= n then flag = 1; 322 put n= flag=; 323 end; 324 put n= flag=; 325 run;

N=9 FLAG=0 N=6 FLAG=1 N=3 FLAG=1 N=3 FLAG=1


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