Date: Thu, 29 Jan 2004 12:12:18 -0700
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject: Re: Leaving Do loop in %Do
Content-Type: text/plain; charset=iso-8859-1
<datametric@CLUB-INTERNET.FR> wrote:
>Your %do statement is open when you do this. Be careful with the nested loops.
Really ?
could you explain this ?
Under what circumstances will the code below cause a problem? The documentation warns against branching into the middle of a loop, but not against branching out.
--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
>>> "SUBSCRIBE SAS-L Stephane" <datametric@CLUB-INTERNET.FR> 01/29/2004 9:28 AM >>>
Your %do statement is open when you do this. Be careful with the nested loops.
Stéphane.
----Message d'origine----
>Date: Wed, 28 Jan 2004 23:54:39 -0700
>De: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
>Sujet: Re: Leaving Do loop in %Do
>A: SAS-L@LISTSERV.UGA.EDU
>
>Use a %GOTO to a label immediately after the loop
>
>=====
>%macro x;
> %do i = 1 %to 12;
> %if &i = 4 %then %goto exitloop;
> &i
> %end;
> %exitloop:
>%mend x;
>
>%put %x;
>=====
>
>prints
>
> 1 2 3
>
>Gotos can lead to trouble, and so their use should be restricted to
>cases like this one.
>
>
>
>
>--
>JackHamilton@FirstHealth.com
>Manager, Technical Development
>Metrics Department, First Health
>West Sacramento, California USA
>
>>>> "taran gujral" <taran_jit@YAHOO.COM> 01/28/2004 8:34 PM >>>
>hello folks ,
>
>i wanted to know how we could leave a %do loop as
>we leave Do loop with a leave .
>
>like
>
>Do i =1 to 5;
>
>if i = 4 then leave;
>end;
>
>what can i use if i have %do loop
>
>thanks
>
>
>---------------------------------
>Chat instantly with your online friends?
>Get the FREE Yahoo!Messenger
>
>
|