楼主: biostatistics
3014 3

【请教】关于 go to 语句 [推广有奖]

  • 0关注
  • 0粉丝

初中生

14%

还不是VIP/贵宾

-

威望
0
论坛币
124 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
143 点
帖子
12
精华
0
在线时间
0 小时
注册时间
2007-5-2
最后登录
2007-7-18

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

有哪位大侠能详细介绍一下利用go to语句进行条件“转移”的用法!

谢谢!

二维码

扫码加我 拉你入群

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

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

关键词:详细介绍 请教 语句

回帖推荐

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

· data info; · if 1<=x<=5 then go to add; · add: sumx+x; · 7 · 323 Because every DATA step contains an implied RETURN at the end of the step, program execution returns to the top of the step after the sum statement is executed. Therefore, an explicit RETURN statement at the bottom of the DATA st ...

本帖被以下文库推荐

沙发
pilihuo_ren 发表于 2007-5-17 08:31:00 |只看作者 |坛友微信交流群

The GO TO statement and the LINK statement are similar. However, a GO TO statement is often used without a RETURN statement, whereas a LINK statement is usually used with an explicit RETURN statement. The action of a subsequent RETURN statement differs between the GO TO and LINK statements. A RETURN statement after a LINK statement returns execution to the statement that follows the LINK statement. A RETURN after a GO TO statement returns execution to the beginning of the DATA step (unless a LINK statement precedes the GO TO statement, in which case execution continues with the first statement after the LINK statement).

GO TO statements can often be replaced by DO-END and IF-THEN/ELSE programming logic.

Example:Use the GO TO statement as shown here.

  • In this example, if the condition is true, the GO TO statement instructs SAS to jump to a label called ADD and to continue execution from there. If the condition is false, SAS executes the PUT statement and the statement that is associated with the GO TO label:

· data info;

· input x;

· if 1<=x<=5 then go to add;

· put x=;

· add: sumx+x;

· datalines;

· 7

· 6

· 323

;

Because every DATA step contains an implied RETURN at the end of the step, program execution returns to the top of the step after the sum statement is executed. Therefore, an explicit RETURN statement at the bottom of the DATA step is not necessary.

  • If you do not want the sum statement to execute for observations that do not meet the condition, rewrite the code and include an explicit return statement.

· data info;

· input x;

· if 1<=x<=5 then go to add;

· put x=;

· return;

· /* SUM statement not executed */

· /* if x<1 or x>5 */

· add: sumx+x;

· datalines;

· 7

· 6

· 323

;

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

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

使用道具

藤椅
pilihuo_ren 发表于 2007-5-17 08:32:00 |只看作者 |坛友微信交流群
Did I answer ur question?

使用道具

板凳
biostatistics 发表于 2007-5-17 09:22:00 |只看作者 |坛友微信交流群

thanks for your answer first!

不知道在我下面的这种情况能否用的上(迭代,我的上一个帖子问的问题);

参数估计过程中的迭代:我给参数(有多个参数)定个初始值,然后根据复杂的过程得到第一个迭代值,这过程需要一个data步1。那么如果这这迭代值与初始值之差大于某个数(这里面又需要一个data步2),用这租迭代值替换初始值,回到data步1,循环,直到他们之差小于某个数,为止。

这种情况下,我想用go to语句跳出data步2,回到data步1。不知可行?或者有其他解决办法没有?

thanks again!

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-26 18:48