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.
In that case, you may want to run SAS in batch mode on your Mac. Here’s how:
- If you find yourself stymied by computers, find someone to help you. These instructions aren’t dangerous, but they do involve some advanced skills.
- Download and install various things
- Buy VMWare Fusion. It costs $80. Install it.
- Get SAS University Edition for Linux. Ignore all the instructions to get Oracle VirtualBox. You’ll be using VMWare Fusion instead.
- 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.
- 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.
- Start SAS in CentOS recovery mode
- Open VMWare Fusion, then choose “File > Open”, and open the “SAS University Edition.vmwarevm” file.
- 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
- Click on “Show All”, click on “Startup Disk”, click on “CD/DVD”, and click Restart
- 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.
- Wait some more, then choose the “Continue” option by pressing “1”, then “Return”
- Wait even more, then press “Return”
- Enable Linux password login in SAS
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
- 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 rootand then enter a new password twice. Then type
passwd sasand enter the same password twice more.
cd /etc/initfollowed by
mv start-ttys.override /etcand
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).
- Press “Control-D” to return to the CentOS recovery command prompt, again with scant indication you did so.
- Start SAS normally
- Press “Command-Control” to free your mouse, then choose “Virtual Machine > Settings” in VMWare.
- Click “Startup Disk”, click “Hard Drive”, then click “Restart”
- 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.
- Fix broken graphics libraries in SAS3
- Log in with username “root” and the password that you set a few steps ago.
yum install libXt libXp libXext libXmu libjpegto install some components SAS should have come with to begin with
- Press “Control-D” to return to the login prompt
- Setup a shared folder between SAS and your Mac
- Create a folder anywhere you like. Your Documents folder is a good place. “SAS-Shared” is a good name for it.
- In VMWare, choose “Virtual Machine > Settings”, click “Sharing”, click the “+” button, and choose the shared folder you just created
- Using your favorite text editor, create a file in that shared folder named “SAS.sh” 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 Fusion.app/Contents/Library/vmrun" \ -gu sas -gp PASSWORD \ runProgramInGuest ~/"Documents/Virtual Machines.localized/SAS University Edition.vmwarevm" \ /bin/bash /mnt/hgfs/SAS-Shared/SAS.sh \ /mnt/hgfs/SAS-Shared/INPUT.sas
PASSWORD is the SAS password you setup earlier and
INPUT.sas 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.
CentOS is an operating system closely related to the one that SAS University Edition uses.↩
Which was the whole point of the CentOS adventure, as the SAS installer is otherwise locked down and can’t be modified↩
This is needed to make SAS graphics work. If you aren’t interested in graphics, you can skip this section↩