全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3556 4
2011-11-11
There are two statements in SAS, leave and continue. Difference between two is seldom not understood.

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
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-11-12 02:29:39
学了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-11-12 05:56:57
简单易懂, i like it
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-11-12 09:16:38
不错,学习了。
那个链接好像打不开啊。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-3-27 13:27:00
踏波铁鞋无觅处
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群