Using do-files and logging

Key points

  1. A do file in STATA helps keep commands organized, reproducible, and trackable, as it stores the commands used in the analysis.
  2. To create a new do file, click on the "New Do-file Editor" button on the toolbar, and then save the file.
  3. Best practice includes adding comments to the do file using two forward slashes (//) before the comment text.
  4. To execute commands from the do file, either click the "Execute" button or use the shortcut "Ctrl + D."
  5. To run a single line of code, select the line and use "Ctrl + D" or click the "Execute" button.
  6. Logging the output is necessary, as the do file only saves the commands, not the output. To start logging, click the "Log Begin" button and save the log file.
  7. Once the log has begun, all output from the Results window will be saved in the log file, which can be accessed later for reference.

Complete and Continue