Creating a do-file

Do-file is an interface in Stata which allows the researcher to compile all the commands and results at one place. Once the commands are stored in do file, one do not need to enter the command again. One can simply run the do file and get all the results at once. Unlike SPSS wherein, the output sheet is automatically generated every time you run a test. All the commands and results in this file can be mailed together.

How to create a do-file?

  1. Open a do file by clicking on the tab encircled below:
Do file helps to store all the commands which can be run later

Do file tab in STATA

  1. The do-file will open in new window (See below):
Using do file allows the researcher to run all the commands at once

Interface of the editor

  1. Based on your previous analysis, you can either “Open” the existing do-files from “File” or can copy the command from the command window in the file.
  2. In order to run or execute the command saved in the do file, click on the “Execute” as shown below:
Along with command , comments can also be stored in do file

Copy command in do file

  1. Final step is to save it. In STATA do-file editor, click on “File” in the menu bar and click “save as”. The file is saved in “.do” format in the folder you wish to save it in.

Note: These files can be created and edited in text editors like notepad or word pad. However, they should be saved in “.do” format or else they will not run in STATA.

Shruti Datt

Shruti Datt

Project Handler at Project Guru
Shruti is B-Tech & M-Tech in Biotechnology. Some of her strengths include, Good interpersonal skills, eye for detail, well devised analytical and decision making skills and a positive attitude towards life. Her aim in life is to obtain a responsible and challenging position where her education and work experience will have valuable application.
She is a true Piscean. She loves doing things to perfection with passion. She is very creative and likes to make personalized gifts for her dear ones, this is actually something that keeps her going. Shruti loves adventure sports and likes river rafting and cliff jumping.
Shruti Datt

Related articles

  • Frequency analysis with SPSS In my previous article “Introducing Data” we discussed about importing files and creation of data sheet in SPSS. Moving further, in this article I will be discussing about the most basic technique which can be applied within SPSS i.e. Frequency Testing.
  • Adding variables to workspace window in MATLAB As discussed in the previous article, workspace is a space wherein the variables used and created in a study are displayed. The variables can also be imported from data files or other programs.
  • Collection of data and data file extensions in Hamlet II The software has different file formats or extensions depending upon the type of analysis. Therefore, it is very important to know the use of every file format and the mode of collection of data.
  • Analysis and interpretation of results using meta analysis The previous article illustrated the manual data entry procedure to facilitate data analysis for performing meta-analysis in comprehensive meta analysis (CMA) application.
  • Start using Mendeley to speed up your writing Mendeley is an online tool to manage, cite and annotate your references in your paper. It is also called a ‘reference manager’.


We are looking for candidates who have completed their master's degree or Ph.D. Click here to know more about our vacancies.