|Author||Chinh Nguyen, StataCorp|
The following topics apply to the GUI version of Stata for the Mac. Advanced starting of the console version of Stata for the Mac can be found in the Getting Started with Stata for Mac manual.
|Warning: The following section is recommended for advanced users only. Administrator access and a good knowledge of Unix may be required. If you are not comfortable editing resource files and do not fully understand any of the instructions, it is highly recommended that you do not attempt any of this faq because of the potential to damage your system.|
The syntax of the command to start Stata from a shell like the Terminal application is
Stata [-option [-option [...]]] [stata_command]
where the options are
|-q||suppress initialization messages|
|-b||set background (batch) mode and log in ASCII text|
|-e||set background (batch) mode and log in ASCII text and exit without prompting when Stata command is completed|
|-s||set background (batch) mode and log in SMCL|
You must add the path to the Stata executable in Stata's application bundle to your shell's PATH. Once that is done, you can invoke Stata from any directory from a shell.
For example, if Stata is installed in /Applications/Stata/, then the path to the Stata executable is /Applications/Stata/Stata.app/Contents/MacOS/.
For Stata/SE, it is /Applications/Stata/StataSE.app/Contents/MacOS/.
For Stata/MP, it is /Applications/Stata/StataMP.app/Contents/MacOS/.
Once the path to the Stata executable is set up, type Stata to launch Stata. If you have Stata/SE, type StataSE to start Stata. If you have Stata/MP, type StataMP to start Stata. Attempting to launch Stata from a symbolic link to the Stata executable will not work.
You can run large jobs in Stata in batch mode. You must have the path to the Stata executable set up (see Starting Stata from a shell in the FAQs).
To run a job in batch mode, open a shell by using, for example, the Terminal application located in /Applications/Utilities/. Change to your data directory, and type
Stata -b do bigjob
This line tells Stata to execute the commands in bigjob.do, suppress all screen output, and route the output to bigjob.log in the same directory. If you desire a SMCL log file rather than an ASCII file, specify -s instead of -b.
While the do-file is executing, a progress bar will appear on the Stata icon in the Dock with a rough percentage of how much of bigjob.do Stata has executed. (Stata calculates this percentage based on the number of characters in bigjob.do, so the percentage may not accurately reflect the amount of time left for the job to complete.)
You can cancel the batch job by bringing Stata to the front and pressing Command-..
Once the do-file is completed, a sound will play and the Stata icon will bounce in the Dock. Bring Stata to the front to close it.
If you want Stata to automatically exit after running the batch do-file, use -e instead of -b.
You do not have to run large do-files in batch mode. Any do-file that you run in batch mode can also be run interactively. Simply start Stata, type log using filename, and then type do filename. You can watch the do-file run, or you can hide Stata while the do-file is running.
You may login to macOS and launch Stata remotely to run a batch file (not use interactively). If you wish to remotely use Stata’s graphical interface, you must use macOS's screen sharing feature or a VNC client Apple Remote Desktop, or VNC Server for Mac OS X (search for VNC at sourceforge.net). Determining which remote desktop application to use and setting it up is beyond the scope of this FAQ.
You must have the path to the Stata executable in your SHELL path (see Starting Stata from a shell above). The environment variable REMOTEHOST must also exist in your shell. You normally do not have to create it, but, if it does not exist, Stata will not remotely execute in batch mode properly. The environment variable REMOTEHOST simply is the machine from which you are remotely connecting. Stata uses this information to determine if you are executing it remotely, so it can suppress the status bar from appearing in the Dock (otherwise, Stata will crash).
You must also be logged in to your Mac OS X machine and the Desktop must be visible. The user that wishes to run Stata remotely must be logged in at the console in addition to logging in remotely. You cannot run Stata remotely if a different user is logged in at the console. In addition, Mac OS X does not allow GUI applications to remotely execute if the Desktop is not visible. This means the login screen must not be visible whether it is because no user is logged in or because you are switching users. Unfortunately, neither limitations are avoidable by Stata.