楼主: jackyyyb
6081 3

求助:在macro中,如何跳出循环 [推广有奖]

  • 0关注
  • 0粉丝

小学生

35%

还不是VIP/贵宾

-

威望
0
论坛币
35 个
通用积分
0
学术水平
2 点
热心指数
2 点
信用等级
1 点
经验
107 点
帖子
6
精华
0
在线时间
0 小时
注册时间
2008-9-12
最后登录
2016-6-3

楼主
jackyyyb 发表于 2008-9-16 13:46:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
例如:有个循环,要求满足条件是就跳出循环执行循环后面的语句。

%do while(...);
%if condition then
跳出循环或者执行下次循环;
%end;
....
...


类似于C语言中的break和continue语句的功能,谁知道?

[此贴子已经被作者于2008-9-16 13:47:09编辑过]

二维码

扫码加我 拉你入群

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

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

关键词:Macro acr CRO Mac condition Macro

回帖推荐

curlxp 发表于2楼  查看完整内容

Leave和continue Leave表示从循环中退出,而continue表示跳过此轮循环,继续下一轮循环。例如 data leave_it;   Interest = .0375;   Total = 100;    do Year = 1 to 100;         Total = Total + Interest*Total;         output;         if Total ge 200 then ...

本帖被以下文库推荐

沙发
curlxp 发表于 2008-9-16 14:10:00
Leave和continue

Leave表示从循环中退出,而continue表示跳过此轮循环,继续下一轮循环。例如

data leave_it;
   Interest = .0375;
   Total = 100;
    do Year = 1 to 100;
         Total = Total + Interest*Total;
         output;
         if Total ge 200 then leave;
     end;
    format Total dollar10.2;
run;

当总数大于或等于200时,则退出循环。

data continue_on;
  Interest = .0375;
  Total = 100;
  do Year = 1 to 100 until (Total ge 200);
      Total = Total + Interest*Total;
      if Total le 150 then continue;
      output;
   end;
format Total dollar10.2;
run;

只要Total小于或等于150,执行语句会跳到loop底部,而忽略output。

已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

初习文,屡试不中;后习武,校场发一矢,中鼓吏;终从医,有小成,攒一延寿良方,服之,卒

藤椅
jackyyyb 发表于 2008-9-16 15:37:00

这个是在data步中的

我问的是在macro中的语句

板凳
PharmD 发表于 2008-9-17 02:03:00

%goto quit;

See this -

-----------------------------------

CONDITIONALLY PROCESS THE DATA SET OR END EXECUTION OF THE MACRO

The %INCLUDE statement retrieves SAS source code from an external file. The SOURCE2 option causes the

inserted SAS statements to appear in the SAS log. The PROCESSDATA.SAS program contains a DATA step and

two PROC steps to read and process the specified data set and create two reports. %QUIT is a macro label; in this

macro, the %QUIT is right before the %MEND. When the %GOTO statement branches macro processing to the

%QUIT label, the macro execution stops.

%include "c:\workshop\ws126\processdata.sas" / source2;

%quit:

%mend expense1;

-------------------------------------

Source: http://www2.sas.com/proceedings/sugi29/126-29.pdf

[此贴子已经被作者于2008-9-17 14:44:53编辑过]

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-12 10:09