Using SAS University Edition in batch mode

If you are like me, you are not a fan of the SAS user interface (and its Cold War design sensibilities) and yet you find yourself occasionally in need of its computational facilities.

If you are even more like me, you enjoy automating tedious things so that you can get on with the fun parts of your life.

If you are that much like me, you probably take this too far.
If you are that much like me, you probably take this too far.

In that case, you may want to run SAS in batch mode on your Mac. Here’s how:

  1. If you find yourself stymied by computers, find someone to help you. These instructions aren’t dangerous, but they do involve some advanced skills.
  2. Download and install various things
    1. Buy VMWare Fusion. It costs $80. Install it.
    2. Get SAS University Edition for Linux. Ignore all the instructions to get Oracle VirtualBox. You’ll be using VMWare Fusion instead.
    3. When you are done downloading SAS University Edition, rename the resulting folder from “SAS-University-Edition” to “SAS University Edition.vmwarevm”. You’ll probably also want to move it somewhere convenient, such as your Documents folder.
    4. Download CentOS1 installer ISO file. I downloaded the “DVD ISO”, but the “Minimal ISO” probably works just fine. You can put this in your Documents folder too.
  3. Start SAS in CentOS recovery mode
    1. Open VMWare Fusion, then choose “File > Open”, and open the “SAS University Edition.vmwarevm” file.
    2. Choose “Virtual Machine > Settings”, click on “Add Device”, choose “CD/DVD”, then click on the pop-up menu, choose “Other”, and choose the CentOS DVD ISO file you downloaded earlier
    3. Click on “Show All”, click on “Startup Disk”, click on “CD/DVD”, and click Restart
    4. At this point, the CentOS recovery mode will load. Wait until the first prompt, and then use up/down arrows and the “Return” key to choose the “Recover” option.
    5. Wait some more, then choose the “Continue” option by pressing “1”, then “Return”
    6. Wait even more, then press “Return”
  4. Enable Linux password login in SAS
    1. Type chroot /mnt/sysimage. This will switch the command line prompt from the CentOS installer to the SAS installer — you won’t have any indication that’s what happened — and the next few commands will affect the SAS installer.2
    2. Next, you will reset the password for the SAS installer. This doesn’t affect SAS, but it lets us make some changes to it later. First type passwd root and then enter a new password twice. Then type passwd sas and enter the same password twice more.
    3. Type cd /etc/init followed by mv start-ttys.override /etc and mv tty-splash.conf /etc. This will allow a password prompt to appear while SAS is running (this, too, is so that we can make changes to SAS later).
    4. Press “Control-D” to return to the CentOS recovery command prompt, again with scant indication you did so.
  5. Start SAS normally
    1. Press “Command-Control” to free your mouse, then choose “Virtual Machine > Settings” in VMWare.
    2. Click “Startup Disk”, click “Hard Drive”, then click “Restart”
    3. Now SAS will load instead of CentOS. However, at the end, rather than displaying instructions for how to use SAS Studio, it will display a Linux login prompt.
  6. Fix broken graphics libraries in SAS3
    1. Log in with username “root” and the password that you set a few steps ago.
    2. Type yum install libXt libXp libXext libXmu libjpeg to install some components SAS should have come with to begin with
    3. Press “Control-D” to return to the login prompt
  7. Setup a shared folder between SAS and your Mac
    1. Create a folder anywhere you like. Your Documents folder is a good place. “SAS-Shared” is a good name for it.
    2. In VMWare, choose “Virtual Machine > Settings”, click “Sharing”, click the “+” button, and choose the shared folder you just created
    3. Using your favorite text editor, create a file in that shared folder named “” with the following contents:
D=`dirname "$1"`
cd "$D"
/opt/sasinside/SASHome/SASFoundation/9.4/sas "$1"

And now you have a SAS install that can be controlled from your Mac command line. To run a SAS program, you will first have to copy that program into the shared folder you created above, and then run a command like this:

"/Applications/VMware" \
  -gu sas -gp PASSWORD \
  runProgramInGuest ~/"Documents/Virtual Machines.localized/SAS University Edition.vmwarevm" \
  /bin/bash /mnt/hgfs/SAS-Shared/ \

where PASSWORD is the SAS password you setup earlier and is the name of your SAS program file.

SAS will run the file you gave it, and produce a log file in the same folder as the input file.

  1. CentOS is an operating system closely related to the one that SAS University Edition uses.

  2. Which was the whole point of the CentOS adventure, as the SAS installer is otherwise locked down and can’t be modified

  3. This is needed to make SAS graphics work. If you aren’t interested in graphics, you can skip this section