Date: Mon, 15 Sep 2008 12:12:09 -0400
Reply-To: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Subject: Re: why this "DO WHILE NOT" cause infinite loop?
In-Reply-To: <200809140200.m8DAmM3D019332@malibu.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii
the difference is covered in this paper:
Do Which? Loop, Until or While?
A Review Of Data Step And Macro Algorithms
http://www2.sas.com/proceedings/forum2007/067-2007.pdf
Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
> -----Original Message-----
> From: owner-sas-l@listserv.uga.edu
> [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Jerry
> Sent: Saturday, September 13, 2008 10:00 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Cc: Jerry
> Subject: why this "DO WHILE NOT" cause infinite loop?
>
> Hi,
>
> With the code below(DO UNTIL approach), I can produce the
> following 2 lines
> in the log
>
> Sex=F Name=Mary
> Sex=M Name=William
>
> /*****DO UNTIL approach************/
> proc sort data=sashelp.class out=class; by sex name; run;
>
> data test1;
> do until (end1);
> DO UNTIL (last.sex);
> set class end=end1;
> by sex;
> end;
> output;
> put sex= name=;
> end;
> stop;
> run;
> /*****************/
>
>
> But with the code (DO WHILE NOT approach) below, it cause an
> infinite loop:
> produce the infinite lines of "Sex= Name=" in the log
>
> /******DO WHILE NOT approach***********/
> proc sort data=sashelp.class out=class; by sex name; run;
>
> data test1;
> do until(end2);
> DO WHILE (NOT last.sex);
> set class end=end2;
> by sex;
> end;
> output;
> put sex= name=;
> end;
> stop;
> run;
> /*****************/
>
> I'm using SAS 9.1.3 sp4.
>
> Could anyone please explain why the infinite loop is
> happening with the DO
> WHILE NOT approach? I thought DO WHILE NOT is equivalent to DO UNTIL.
>
> Thanks.
>
>
|