Introduction to Stata

9. Using do and log files

All Stata analyses should be done using do-files. A do-file is a series of commands to be executed in the correct sequence. Do-files document what you did and they are also a good way to identify and correct any mistakes that have been made. Log-files are Stata output files. They also include the documentation of what you did and also your results. A new do-file starts with opening a log file and ends with closing the log.


There are two key commands for using do and log files:

Table 7


Example of a Do-file:

Do-file example


You can add comments to your do-file using and asterisk (*) in front of the comment text, as in the example above.


task Task:   Do and log files

Insert all your commands to a do-file (such as the example above), run it and inspect (look at) the log file.