Using .do files with Stata
In
order to make multiple runs, save particular runs (or particular statistical
analyses) for later reference, save the 'history' of your analysis,
and make your analysis more efficient, I recommend that you learn to
use .do files. .do
files are text files comprised of STATA commands that will execute sequentially
and then turn control over to the user after the last statement.
To use .do files, you can create them in the .do file editor within
STATA. On the other hand, I prefer a slightly more cumbersome
approach that becomes more efficient upon multiple runs.
My 'algorithm' for using .do files:
- Create/Open the folder where your data, output, and .do file reside, using either My Computer or Windows Explorer.
- Open Windows Notepad on a new text file that you will save as a .do file (e.g. demo.do). STATA will recognize the .do as a STATA .do file and automatically execute it when you double-click it.
- Edit the .do file and save any changes.
- Make sure you have named it with the .do extension;
- You have set File type to All Files; and
- Do not close the .do file. Minimize if desired when you are ready to run it.
- Double-click the .do file
- STATA will run the commands in the .do file and leave you with STATA open (unless you put an end statement in it!).
- Examine your output.
- Make changes in your .do file as desired, save it, and repeat steps 1-4.