Thursday, April 18, 2019

How to run multiple STATA instances on macOS

As we all know, we can run multiple instances of STATA on a Windows machine, but on the macOS, only one instance can be active at the same time.  Sometimes, we need to leverage parallel/extra computing power by utilizing more than one instance of STATA on a Mac computer. So, how can we run multiple instances of STATA on the Mac?  In the following, I summarize 3 methods for you to choose from.

  1.  Terminal Command
You can use the terminal command to execute two or more STATA instance.  First, find out the path of STATA on your computer.  For example, my STATA was installed on the secondary hard drive, and the path is "/Volumes/MacHD Storage/Applications/Stata".  Copy the path from Finder to the clipboard.  Second, open the terminal window and type in the following command

open -n "/Volumes/MacHD Storage/Applications/Stata/StataSE.app" 

Replace the path with your path, and the name of STATA application when necessary.  Last, press Enter.

      2.   Alias
If you feel annoying to type the length command each time when you want to run another instance of STATA, you can save it as an alias.  First, open the terminal, then type in the following command

sudo nano /.bash_profile

This command allows using command line based text editor GNU nano to edit the profile file.  Remember this has to be done under the superuser privilege so you will need to type in your superuser password.  Second, type in the following command:

alias STA=open -n "/Volumes/MacHD Storage/Applications/Stata/StataSE.app" 

This step is to make an alias of the command scripts in profile, and the alias is called STA.
Press CTL+O to save the file, and press CTL+X to exit the editor.  Then log out and log in again.  Next time when you need to run another instance, just open the terminal and type in STA, and press Enter.

       3.  Executive File
You can also make an executive file that is doable in macOS (UNIX).  Open any coding text editor, such as the BBEdit, Notepad++ or even Xcode, create a new text file, set the encoding format to be UNIX LF, set the text profile to be "Unix Shell Scripts", then copy and paste the following code (change the path when necessary) to the text editor:

#!/bin/bash

open -n "/Volumes/MacHD Storage/Applications/Stata/StataSE.app"    


Then save it as a .sh file.  Open Finder, find the .sh file you just saved and remove ".sh" from the name, then you will notice that the text file becomes an executive file.  Next time when you need to run another instance, just double click the executive file.

(Or:

If it does not work, you will need to use a formal way.  Suppose you named the ,sh file as STA_MI.sh, put in on the desktop.  Open terminal, type in:

sudo chmod +x "~/Desktop/STA_MI.sh"   

Then this file will be assigned an executable permission.)

I hope these methods help.  You can leave any questions regarding this in the comment section, and I will answer them when possible.

References:
1. https://www.stata.com/statalist/archive/2010-08/msg00113.html
2. https://www.techradar.com/how-to/computing/apple/terminal-101-creating-aliases-for-commands-1305638
3. https://www.macobserver.com/tmo/article/os-x-how-to-convert-a-terminal-command-into-a-double-clickable-desktop-file

Saturday, April 6, 2019

STATA 15 SE seems to loosely limit cores on macOS than on Windows

As we all know that the STATA SE edition can only utilize one core, which is essentially one thread.  But, the things might be different on macOS and Linux.  I have been running the same simulation code, and found that the performance seems to be substantially better on macOS and Linux compared to it is on a PC.  I will post details later if I confirm this finding.