data leave;
do i = 1 to 5;
do j = 1 to 5;
if j = 2 or j = 4 then leave;
output;
end;
end;
run;
Here SAS will leave inner do loop completely once the first condition j=2 gets satisfied. So in output you will never have j = 2 or 3 or 4 or 5.
OUTPUT:
i j
1 1
2 1
3 1
4 1
5 1
Same program with continue statement.
data continue;
do i = 1 to 5;
do j = 1 to 5;
if j = 2 or j = 4 then continue;
output;
end;
end;
run;
Here SAS will skip the inner loop for both conditions j = 2 and j=4, but it will not completely leave the loop. So ouput for this will look like
OUTPUT:
i j
1 1
1 3
1 5
2 1
2 3
2 5
. .
. .
. .
5 3
5 5
【转载】http://dataproc.blogspot.com/2009/11/do-leave-loop-and-continue.html





雷达卡



京公网安备 11010802022788号







