Date: Sat, 13 Sep 2008 22:00:05 -0400
Reply-To: Jerry <i89rt5@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jerry <i89rt5@GMAIL.COM>
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.