Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: RE: Debugging: reporting line number of loop or do-file causing error

From   "Nick Cox" <>
To   <>
Subject   st: RE: Debugging: reporting line number of loop or do-file causing error
Date   Thu, 29 Jul 2010 12:31:35 +0100

This area is the subject of intermittent discussion, for example at the recent Stata Conference in Boston. What you report is from one point of view a feature, as reporting step-by-step progress through a loop of hundreds (thousands (...)) of steps would bloat traces mightily and would surely be a matter for frequent complaint. But equally many user-programmers would echo your experience. 

For the moment, adding your own debugging lines designed to catch what is most problematic is I believe the only game in town. Printing out something important or sensitive is however likely to be more informative than quite what you have here, except that I don't know the context. 


Aleksander Rutkowski

Is there any convenient way to make Stata report (together with an
error message) the line number of a loop or a line number of a do-file
which is causing an error?  In general, I think this is an important
feature needed for efficient debugging.

When loops are executed, the commands are not reported in the results
window, so it is difficult to quickly identify which command causes an
error. So far, I used the following solution, but it is not very

local i 0
forval j = 1/100 {
   local ++i
   di "Now executing line `i'..."
   ...some command here...
   local ++i
   di "Now executing line `i'..."
   ...some command here...

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index