Title | Running Stata for Windows in batch mode | |
Author | Jeremy B. Wernow, StataCorp |
You can run large jobs in Stata in batch mode and create log files of all output in a few different ways on a Windows machine. We will explain three of these methods in this FAQ.
One method is to click on the Start menu and select Run.... If your Stata installation directory is the default location of “C:\Program Files\Stata15”, then in the text box type
"C:\Program Files\Stata15\StataMP" /b do c:\data\bigjob.do
This command tells Stata to execute the commands in bigjob.do, suppress all screen output, and route the output to bigjob.log in C:\Program Files\Stata15. You must give the full path of the Stata executable, and the log file will be saved in this installation directory.
The /b option will require that you click on OK before Stata can exit. If you use the /e option, no such action will be required.
"C:\Program Files\Stata15\StataMP" /e do c:\data\bigjob.do
If you receive an error message of r(608) when attempting method one, then you do not have write permissions to the Stata installation directory. These permissions are needed to create the log file. In this case, you can use the second or third method and specify a path for the log file to be saved.
If you would like the log file to be saved in a specific directory, then you can click on the Start menu and choose Run.... (Note: If you are working on Windows 7 or Vista and do not see the Run... button, then you need to click on Start -> All Programs -> Accessories -> Run. For Windows 8, go the the Desktop and use the Windows key + R on your keyboard to access Run.) Then, in the text box type
cmd
This will open a command prompt. You can then change the current directory to the one you want the log file saved to using the cd command. For example, typing the following will run bigjob.log, suppress all screen output, and route the output to bigjob.log in C:\data.
cd C:\data "C:\Program Files\Stata15\StataMP" /e do c:\data\bigjob.do
You must specify the location of the Stata executable when using this method.
Another common method is to use the Task Scheduler, which is installed on most Windows machines. You can usually find the Task Schedular by going to the Control Panel or by going to Start -> Programs -> Accessories> -> System Tools -> Task Scheduler. Once you have opened the Task Scheduler, click on “Create Task” and follow the steps of the Task Schedule Wizard to schedule a do-file to run in batch mode (must specify the /b or /e option). In the “Start in” text box, type the path where you would like the log file to be saved. When this file runs, all output will be suppressed and written to a log file that will be saved in the path specified.
You can read more about this feature in [GSW] B.5 Stata batch mode.
Learn
Free webinars
NetCourses
Classroom and web training
Organizational training
Video tutorials
Third-party courses
Web resources
Teaching with Stata
© Copyright 1996–2024 StataCorp LLC. All rights reserved.
×
We use cookies to ensure that we give you the best experience on our website—to enhance site navigation, to analyze usage, and to assist in our marketing efforts. By continuing to use our site, you consent to the storing of cookies on your device and agree to delivery of content, including web fonts and JavaScript, from third party web services.
Cookie Settings
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
This website uses cookies to provide you with a better user experience. A cookie is a small piece of data our website stores on a site visitor's hard drive and accesses each time you visit so we can improve your access to our site, better understand how you use our site, and serve you content that may be of interest to you. For instance, we store a cookie when you log in to our shopping cart so that we can maintain your shopping cart should you not complete checkout. These cookies do not directly store your personal information, but they do support the ability to uniquely identify your internet browser and device.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.