Posted on 30 August 2010 by Mitch Abdon
-cap- (short for capture) is a dangerous but useful code . It supresses all output, including error messages, and proceeds to the next line regardless of any error. For example:
cap drop varname
/* Stata will execute “drop varname,” but if varname does not exist, it will suppress the error report “variable varname not found” and continue on to the next line. If you wish to see the error message, type: “cap noisily drop varname” */
[Note: Stata ignores everything inside /* */ ]
Have you been constantly bothered by error messages such as “log file already open” when you are re-executing your do-file? Try -cap-.
[Thanks to Utsav for introducing me to -cap-.]