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:
  1. Create/Open the folder where your data, output, and .do file reside, using either My Computer or Windows Explorer.
  2. 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.
    1. Edit the .do file and save any changes.  
      1. Make sure you have named it with the .do extension;
      2. You have set File type to All Files; and 
      3. Do not close the .do file.  Minimize if desired when you are ready to run it.
    2. Double-click the .do file
      1. STATA will run the commands in the .do file and leave you with STATA open (unless you put an end statement in it!).
    3. Examine your output.
    4. Make changes in your .do file as desired, save it, and repeat steps 1-4.
Here is a sample .do file:  approval_spec.do