Using do-files and logging
Download
Key points
- A do file in STATA helps keep commands organized, reproducible, and trackable, as it stores the commands used in the analysis.
- To create a new do file, click on the "New Do-file Editor" button on the toolbar, and then save the file.
- Best practice includes adding comments to the do file using two forward slashes (//) before the comment text.
- To execute commands from the do file, either click the "Execute" button or use the shortcut "Ctrl + D."
- To run a single line of code, select the line and use "Ctrl + D" or click the "Execute" button.
- 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.
- 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.