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 at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Debugging: reporting line number of loop or do-file causing error
Date   Thu, 29 Jul 2010 13:29:05 +0200

<> 

You can always


*************
set trace on
*************

which shows you the offending command.


HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Aleksander Rutkowski
Gesendet: Donnerstag, 29. Juli 2010 13:06
An: statalist@hsphsun2.harvard.edu
Betreff: st: Debugging: reporting line number of loop or do-file causing error

Hello,

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
convenient:

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...
   ...etc...
}

Alek
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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