[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Tracing in Stata

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Tracing in Stata
Date   Tue, 5 May 2009 18:49:31 +0200


In such cases, I either look at the error very closely and try to figure out
which command could possibly have caused it - most of the time that narrows
it down quite substantially. Or I let my template below record the entire
-trace- with -tracedepth- at infinity (grab a cup of tea in the meantime),
have it turned into a pdf and search it in the pdf reader for the offending

//to log in an additional log and have it transferred to pdf

//can set -linesize-
set linesize 120

//close if open
capt log close newlog
di in red _rc

log using mylog.smcl, name(newlog) replace
//do whatever you want in the log

//trace the thing with Ben Jann`s tool

//or use conventional set trace on/off
//set trace on

//set trace off

log close newlog

translate mylog.smcl, replace
//need Miktex utilities running on computer for this step
capt erase
!start mylog.pdf


-----Ursprüngliche Nachricht-----
[] Im Auftrag von John Bates
Gesendet: Dienstag, 5. Mai 2009 18:41
An: Stata
Betreff: st: Tracing in Stata



Is there any way to figure what line in a for loop Stata is erroring on?
The best way I know of is to do -set tracedepth 1- and -set trace on-.  This
works, BUT it's annoying because Stata traces down into function calls that
I don't care about.  For example, assume there is an error somewhere in the
following (potentially very long) for loop:

forval x = 1/20 {

I just want to know which line in the for loop the error is without having
trace go down into the regress ADO code etc.  This is not a problem outside
of the for loop because Stata goes line-by-line down do files by default.
All in all, a very minor issue, but one that frustrates me.  Ideally there
would be a -set tracedepth 0- option which would address this.



*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index