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. 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 > New”, then click “Import an existing virtual machine”, then click “Continue”.
    2. Click on “Choose File”, then choose the SAS University Edition download file (named something useful like “unvbasicvapp__9411015__ova__en__sp0__1.ova”).
    3. Wait a while while the import process grinds, then click ”Customize Settings”
    4. Save the virtual machine in your Home > Documents > Virtual Machines, and name it “SAS University Edition”.
    5. In the settings window, 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
    6. Click on “Show All”, click on “Startup Disk”, click on “CD/DVD”, and click Restart
    7. 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 “Rescue” option from the “Troubleshooting” submenu.
    8. Wait some more, then choose the “Continue” option by pressing “1”, then “Return”
    9. 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. Optional: install Bonjour on your SAS virtual machine
    1. Log in with username “root” and the password that you set a few steps ago.
    2. Type su root to switch to the admin user
    3. Type yum install avahi to install Bonjour
    4. Type sed -f 's/#host-name=foo/host-name=sas/g' /etc/avahi/avahi-daemon.conf to configure Bonjour
    5. Type service acahi-daemon restart to start Bonjour
    6. Press “Control-D” twice 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/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.

If you installed Bonjour, then you can also access SAS in your browser using sas.local instead of an IP address.

  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