Introduction

What Is Debugging?

Debugging is the process of removing logic errors from a program. Unlike syntax errors, logic errors do not stop a program from running. Instead, they cause the program to produce unexpected results. For example, if you create a DATA step that keeps track of inventory, and your program shows that you are out of stock but your warehouse is full, you have a logic error in your program.
To debug a DATA step, you could do any of the following tasks:
  • copy a few lines of the step into another DATA step, execute it, and print the results of those statements.
  • insert PUT statements at selected places in the DATA step, submit the step, and examine the values that are displayed in the SAS log.
  • use the DATA step debugger.
While the SAS log can help you identify data errors, the DATA step debugger offers you an easier, interactive way to identify logic errors, and sometimes data errors, in DATA steps.

What Is the DATA Step Debugger ?

The DATA step debugger is part of Base SAS software and consists of windows and a group of commands. By issuing commands, you can execute DATA step statements one by one and pause to display the resulting variable values in a window. By observing the results that are displayed, you can determine where the logic error lies. Because the debugger is interactive, you can repeat the process of issuing commands and observing the results as many times as needed in a single debugging session. To invoke the debugger, add the DEBUG option to the DATA statement and execute the program.
The DATA step debugger enables you to perform these tasks:
  • execute statements one by one or in groups
  • bypass execution of one or more statements
  • suspend execution at selected statements, either in each iteration of DATA step statements or on a condition that you specify, and resume execution on command
  • monitor the values of selected variables and suspend execution at the point a value changes
  • display the values of variables and assign new values to them
  • display the attributes of variables
  • receive help for individual debugger commands
  • assign debugger commands to function keys
  • use the macro facility to generate customized debugger commands