|
Chapter Contents |
Previous |
Next |
| Language Reference |
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 statements above could be better written
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 GOTO statements when they refer to a label above the GOTO statement; otherwise, an infinite loop is possible.
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.