BREAK

Suspends program execution at an executable statement.
Category: Manipulating Debugging Requests
Alias: B

Syntax

BREAK location <AFTER count> <WHEN expression> <DO group>

Required Argument

location
specifies where to set a breakpoint. Location must be one of these:
label
a statement label. The breakpoint is set at the statement that follows the label.
line-number
the number of a program line at which to set a breakpoint.
*
the current line.

Optional Arguments

AFTER count
honors the breakpoint each time the statement has been executed count times. The counting is continuous. That is, when the AFTER option applies to a statement inside a DO loop, the count continues from one iteration of the loop to the next. The debugger does not reset the count value to 1 at the beginning of each iteration.
If a BREAK command contains both AFTER and WHEN, AFTER is evaluated first. If the AFTER count is satisfied, the WHEN expression is evaluated.
Tip:The AFTER option is useful in debugging DO loops.
WHEN expression
honors a breakpoint when the expression is true.
DO group
is one or more debugger commands enclosed by a DO and an END statement. The syntax of the DO group is the following:
DO; command-1<...;command-n;> END;
command
specifies a debugger command. Separate multiple commands by semicolons.
A DO group can span more than one line and can contain IF-THEN/ELSE statements, as shown:
IF expression THEN command; <ELSE command;>
IF expression THEN DO group; <ELSE DO group;>
IF evaluates an expression. When the condition is true, the debugger command or DO group in the THEN clause executes. An optional ELSE command gives an alternative action if the condition is not true. You can use these arguments with IF:
expression
specifies a debugger expression. A non-zero, nonmissing result causes the expression to be true. A result of zero or missing causes the expression to be false.
command
specifies a single debugger command.
DO group
specifies a DO group.

Details

The BREAK command suspends execution of the DATA step at a specified statement. Executing the BREAK command is called setting a breakpoint.
When the debugger detects a breakpoint, it does the following:
  • checks the AFTER count value, if present, and suspends execution if count breakpoint activations have been reached
  • evaluates the WHEN expression, if present, and suspends execution if the condition that is evaluated is true
  • suspends execution if neither an AFTER nor a WHEN clause is present
  • displays the line number at which execution is suspended
  • executes any commands that are present in a DO group
  • returns control to the user with a > prompt
If a breakpoint is set at a source line that contains more than one statement, the breakpoint applies to each statement on the source line. If a breakpoint is set at a line that contains a macro invocation, the debugger breaks at each statement generated by the macro.

Example

  • Set a breakpoint at line 5 in the current program:
    b 5
  • Set a breakpoint at the statement after the statement label eoflabel:
    b eoflabel
  • Set a breakpoint at line 45 that will be honored after every third execution of line 45:
    b 45 after 3
  • Set a breakpoint at line 45 that will be honored after every third execution of that line only when the values of both DIVISOR and DIVIDEND are 0:
    b 45 after 3 
           when (divisor=0 and dividend=0)
  • Set a breakpoint at line 45 of the program and examine the values of variables NAME and AGE:
    b 45 do; ex name age; end;
  • Set a breakpoint at line 15 of the program. If the value of DIVISOR is greater than 3, execute STEP. Otherwise, display the value of DIVIDEND.
    b 15 do; if divisor>3 then st; 
               else ex dividend; end;

See Also

Commands: