help trace
-------------------------------------------------------------------------------
Title
[P] trace -- Trace program execution
Syntax
Whether to trace execution of programs
set trace { on | off }
Show # levels in tracing nested programs
set tracedepth #
Whether to show the lines after macro expansion
set traceexpand { on | off } [, permanently ]
Whether to display horizontal separator lines
set tracesep { on | off } [, permanently ]
Whether to indent lines according to nesting level
set traceindent { on | off } [, permanently ]
Whether to display nesting level
set tracenumber { on | off } [, permanently ]
Highlight pattern in trace output
set tracehilite "pattern" [, word ]
Description
set trace on traces the execution of programs for debugging. set trace
off turns off tracing after it has been set on.
set tracedepth specifies how many levels to descend in tracing nested
programs. The default is 32000, which is equivalent to infinity.
set traceexpand indicates whether the lines before and after macro
expansion are to be shown. The default is on.
set tracesep indicates whether to display a horizontal separator line
that displays the name of the subroutine whenever a subroutine is entered
or exited. The default is on.
set traceindent indicates whether displayed lines of code should be
indented according to the nesting level. The default is on.
set tracenumber indicates whether the nesting level should be displayed
at the beginning of the line. Lines in the main program are preceded
with 01; lines in subroutines called by the main program, with 02; etc.
The default is off.
set tracehilite causes the specified pattern to be highlighted in the
trace output.
Options
permanently specifies that, in addition to making the change right now,
the traceexpand, tracesep, traceindent, and tracenumber settings be
remembered and become the default settings when you invoke Stata.
word highlights only tokens that are delimited by nonalphanumeric
characters. These would include tokens at the beginning or end of
each line that are delimited by nonalphanumeric characters.
Examples
. cii 10 1
Trace execution of programs
. set trace on
. cii 10 1
Suppress printing of trace separator lines
. set tracesep off
. cii 10 1
Turn on tracesep
. set tracesep on
Suppress printing of lines after macro expansion
. set traceexpand off
. cii 10 1
Turn on traceexpand
. set traceexpand on
Display the nesting level
. set tracenumber on
. cii 1 27, poisson
Do not indent lines of code according to their nesting level
. set traceindent off
. cii 1 27, poisson
Turn off tracenumber
. set tracenumber off
Turn on traceindent
. set traceindent on
Highlight poisson in the code
. set tracehilite poisson
. cii 1 27, poisson
Turn off trace
. set trace off
Also see
Manual: [P] trace
Help: [P] program, [R] query; [P] profiler