Language Reference |
jumps to a new statement
where label is a labeled statement. Execution jumps to this statement. A label is a name followed by a colon (:).
The GOTO (or GO TO) statement directs IML to jump immediately to the statement with the given label and begin executing statements from that point. Any IML statement can have a label, which is a name followed by a colon preceding any executable statement.
GOTO statements are usually clauses of IF statements. For example:
if x>y then goto skip;
y=log(y-x);
yy=y-20;
skip: if y<0 then
do;
more statements
end;
The function of GOTO statements is
usually better performed by DO groups.
For example, the preceding statements could be better written
as follows:
if x<=y then
do;
y=log(y-x);
yy=y-20;
end;
more statements
CAUTION: You can only use the GOTO statement inside a module or a DO group. As good programming practice, you should avoid using a GOTO statement when it refers to a label preceding the GOTO statement; otherwise, an infinite loop is possible.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.