楼主: tj0412ymy
3554 4

[原创博文] SAS中Leave Statement 和Continue Statement的区别 [推广有奖]

  • 2关注
  • 48粉丝

已卖:4314份资源

副教授

65%

还不是VIP/贵宾

-

威望
0
论坛币
11512 个
通用积分
12.7575
学术水平
72 点
热心指数
91 点
信用等级
64 点
经验
29292 点
帖子
545
精华
0
在线时间
1203 小时
注册时间
2009-3-10
最后登录
2024-2-15

楼主
tj0412ymy 发表于 2011-11-11 15:00:35 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
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
二维码

扫码加我 拉你入群

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

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

关键词:statement Statemen continue Statem State

沙发
ordinaryxing 发表于 2011-11-12 02:29:39
学了

藤椅
bigbluelake 发表于 2011-11-12 05:56:57
简单易懂, i like it

板凳
zhentao 发表于 2011-11-12 09:16:38
不错,学习了。
那个链接好像打不开啊。

报纸
melodygong 发表于 2013-3-27 13:27:00
踏波铁鞋无觅处

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 11:06