Tell me, where did I go wrong


If you are Filipino, you are most likely singing the title by now :)

Looking for a missing bracket, a misplaced comma, or a space that shouldn’t be there—or debugging in general—can be a pain sometimes. When the usual error message fails to point out where you messed up, try turning trace on to track down the error. trace literally traces the execution of programs. It echoes the lines that Stata executes internally. Reading through the whole thing on your results window can be daunting but you don’t really have to go through those. You just need to know which line it stops executing and see why it stopped there. To turn on trace, type:

set trace on
And.. don’t forget to turn it off when you don’t need it. They can be really very long.

set trace off
Next time you wonder where you went wrong, use trace before you lose your mind. For more options, see help set trace.

Now, continue with the singing.. “what did I do to make you change your mind completely..”

 

Blah-blah-blah about do-files


Data analysis in Stata may be carried out by interactive mode using the Command window, by using the drop down menu, or by executing a set of Stata commands written in a do-file. It is most likely that you will be using a combination of these rather than using one method exclusively. Making use of the command window or GUI interface are ways to easily get acquainted with Stata.

Using Stata interactively allows you to use Stata on the fly by submitting a command line in the Command window or clicking options from the drop down menu. You can load, explore, manage, and analyse your data in this manner. Clicking away is particularly useful if you do not know the command; and typing away is convenient particularly in the early part of analysis when you are in the process of getting to know your data or when you are just figuring out what to do.

The drawback, however, is that what you do interactively is lost when you exit Stata. You may have saved your output (a table or a chart) but the process from which it resulted is gone and replicating or modifying your work may prove difficult and often impossible. Also, it will be difficult to audit your work.

The advice to keep an organized, self-explanatory record (a do-file or a set of do-files) of the processes you have been through throughout your work—from loading your data to cleaning it to producing tables and charts—cannot be overemphasized. Easier said than done.