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.
- 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 > New”, then click “Import an existing virtual machine”, then click “Continue”.
- Click on “Choose File”, then choose the SAS University Edition download file (named something useful like “unvbasicvapp9411015ovaensp0__1.ova”).
- Wait a while while the import process grinds, then click ”Customize Settings”
- Save the virtual machine in your Home > Documents > Virtual Machines, and name it “SAS University Edition”.
- 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
- 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 “Rescue” option from the “Troubleshooting” submenu.
- 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
- 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 - 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 typepasswd sas
and enter the same password twice more. - Type
cd /etc/init
followed bymv start-ttys.override /etc
andmv 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.
- Type
- 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.
- Optional: install Bonjour on your SAS virtual machine
- Log in with username “root” and the password that you set a few steps ago.
- Type
su root
to switch to the admin user - Type
yum install avahi
to install Bonjour - Type
sed -f 's/#host-name=foo/host-name=sas/g' /etc/avahi/avahi-daemon.conf
to configure Bonjour - Type
service acahi-daemon restart
to start Bonjour - Press “Control-D” twice 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/SAS University Edition.vmwarevm" \\
/bin/bash /mnt/hgfs/SAS-Shared/SAS.sh \\
/mnt/hgfs/SAS-Shared/INPUT.sas
where 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.
If you installed Bonjour, then you can also access SAS in your browser using sas.local
instead of an IP address.