Date: Tue, 18 Jul 2000 20:53:29 GMT
Reply-To: "John M. Wildenthal" <jmwildenthal@MY-DEJA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "John M. Wildenthal" <jmwildenthal@MY-DEJA.COM>
Organization: Deja.com - Before you buy.
Subject: Re: SAS: Iterative do loops with until statement
In article <00Jul18.152555edt.118081@gateway.viropharma.com>,
"Hudson, Spencer" <shudson@VIROPHARMA.COM> wrote:
> 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
Since there is a variable assignment between the DO and UNTIL, it is an
iterative do loop, not a DO UNTIL do loop.
How are the arguments to n being passed? An array or a macro variable
or hard coded? Different methods of passing suggest different
solutions.
Sent via Deja.com http://www.deja.com/
Before you buy.
|