SAS via Virtual Linux

Virturalization is a method of running one operating system inside another. Sort of like running an OS as a videogame.

Glossary

We will use a few specific concepts from the world of virturalization:

  • The term Host refers to your normal operating system, e.g. Mac, Windows or Linux.

  • The term Virtual Machine or just VM refers to the system being virtualized (virtual operating system plus virtual harddrive)

  • The term Virtualization software refers to the software that controls the VM. The software handles the signals in and out of the VM such that it will think it is installed on “real” hardware

Most modern computers have virtualization capabilities build into the hardware and can thus host a virtualized OS.

We will be using the VirtualBox virtualization software as it is freely available for all relevant operating systems.

General requirements

  • Enough memory

    Netbooks and similar might not be suitable for hosting a VM

  • Enough space on your harddrive. While our downloadable VMs are only about 4.5 Gb, their configuration allows them to grow up to 32 Gb as their virtual harddrive gets filled up

  • For tests to see if your computer support virtualization see System check.

General note

A VM is a full operating system. Thus you should close it down properly inside the VM.

Do not simply close the window in which the VM is running. That corresponds to removing the power supply and may damage the VM filesystem.

Installation steps

The general steps for installing the downloadable VM are as follows

  1. Installing the Virtualization software.

  2. Installing the VirtualBox extension pack (which allows the VM to communicate with the host, for exchanging files etc)

  3. Downloading and importing the VM.

  4. Set up shared folders, such that you can exchange files with the VM.

  5. Additionals if Danish Mac keyboard, such that we can get the elusive $, [], {}, @ and \ to work.

Do not worry, it is not as hard as it looks.

See also the note about using the SAS VM

Installing VirtualBox

For more detailed information please refer to the relevant part of the VirtualBox online manual for further info.

MAC OS X

  1. Download the current .dmg file for Mac (OS X) hosts from https://www.virtualbox.org/wiki/Downloads
  2. Double click the .dmg file and an installation window appears.
  3. Double click the VirtualBox.pkg icon to install VirtualBox
  4. VirtualBox is now to be found in the Applications folder (you might want to pin it to the docker).

Now proceed to installing the VirtualBox Extension pack

Windows

Should work on both 7 and 8 (and properly also 10)

  1. Download the current .exe file for Windows hosts from https://www.virtualbox.org/wiki/Downloads

    The .exe file contains the installation for both 32- and 64-bit host architectures.

  2. Double click the .exe file and an installation dialog appears.

    1. Window: Setup Wizard Click: Next
    2. Window: Custom Setup Click: Next
    3. Window: Custom Setup Click: Next
    4. Window: Warning Network Interfaces Click: Yes
    5. Window: Ready to Install Click: Install
    6. Window: Software Installation Warning Click: Continue Anyway

      There may be several of these warnings.

    7. Window: Installation Complete Click: Finish

Comments
  • Depending on your Windows configuration, you may see warnings about unsigned drivers or similar. Please select Continue on these warnings as otherwise VirtualBox might not function correctly after installation.

  • The installer will create a VirtualBox group in the Windows Start menu which allows you to launch the application and access its documentation.

  • With standard settings, VirtualBox will be installed for all users on the local system.

Linux

In most cases VirtualBox will be in the package repositories or you can ask your system to add a special repository for VirtualBox software. There are many guides for this online, so we will skip this part.

Installing the VirtualBox Extension pack

For more detailed information please refer to the relevant part of the VirtualBox online manual for further info.

  1. Download the current extension pack from https://www.virtualbox.org/wiki/Downloads

    Look for All supported platforms. The downloaded file will have the extension: .vbox-extpack.

  2. To install on Mac or Windows:

    • Double click the downloaded file. It should already be associated with VirtualBox which will then install the extension

    On Linux things may be a little complicated depending on how you installed VirtualBox. On some systems double clicking the .vbox-extpack might be enough. Otherwise:

    1. In the VirtualBox Manager window, click: File -> Preferences...
    2. In the VirtualBox - Settings window, click: Extensions
    3. In the VirtualBox - Settings - Extensions window, click on the Add Package icon — a blue box with an yellow arrow pointing down — in the upper right part of the window.
    4. In the Select an extension package file window, use the browsing facilities to find the downloaded extension pack file and click Open
    5. In the VirtualBox - Question window, click: Install
    6. In the VirtualBox License window, read or scroll to the bottom, and click: I Agree
    7. In the VirtualBox - Information window, click: OK
    8. In the VirtualBox - Settings - Extensions window, click: OK

Downloading and importing the SAS VM

First visit MATH-AU to download the SAS VM. There are four combinations to choose from:

Note that the keyboard layout can be changed afterwards.

  • SAS 9.3 32-bit is installed and running on the two 32-bit virtual machines.
  • SAS 9.4 64-bit is installed and running on the two 64-bit virtual machines.
  • Lubuntu is Ubuntu running the light weight LXDE window manager.

Recommendation

We recommend using the 32 bit version even if the Host is 64 bit. Only use the 64 bit version if you really need SAS 9.4 and your host is 64 bit.

Start VirtualBox

On Mac it is found in the Applications folder.

On Windows it is in the Start menu (or equivalent).

Import the VM

For more detailed information please refer to the relevant part of the VirtualBox online manual for further info.

To import the .ova file into VirtualBox:

  1. In the VirtualBox Manager window, click:

    File -> Import Appliance...
    
  2. In the Import Virtual Appliance window, click: Open appliance...

  3. In the Select an appliance to import file browser window, select the downloaded .ova file and click: Open
  4. In the Import Virtual Appliance window, click: Next -> Import

The import may take a few minutes. Once the file is imported and the new VM is tested, then the .ova file can be deleted.

Starting the VM

Choose the VM in the VirtualBox manager and click the Start button (a green arrow).

Usually double clicking the VM also starts the VM.

About the VM

  • Once the VM is started, Linux boots up. It logs in automatically.
  • On the Desktop you will find

    • A file named password in which the password for the user sas is listed. You will need this to update the VM or to install extra Linux packages.

      In order to perform tasks as the superuser (root) prepend the sudo command as in sudo ls -l to list the files in the current folder as the superuser.

    • A file called SharedFolders explaining how to setup shared folders, we will handle this is in a moment.

    • An icon labeled Shared folders, once setup, shared folders appear here.

    • An icon to open SAS.

Note: Unlike on Windows, on Linux one cannot associate .sas files with SAS and have SAS open the file in the SAS program editor. On Linux one can execute SAS on a file via

sas file.sas

so we have no way of automatically opening the .sas file in the SAS program editor. On Linux, one will instead get a standard text editor if you double click a .sas file.

Important: Once the VM is running it takes over the keyboard and mouse. Thus shortcuts like Alt+Tab now apply inside the VM. To escape to the host, press the Host key on the keybord, it is listed in the lower right hand corner of the VM window. On some systems it is Right CTRL, on others something else (it is configurable).

Setting up shared folders

This involves creating or location a folder on the host that we will pinpoint as the shared folder, that is files in this folder will be accessible from both the Host and the VM

  1. Create or decide on a folder on the Host and place some file in it (such that we later on can verify that we got access to the right one).
  2. Start VirtualBox
  3. Choose the relevant VM, and left click it in the manager
  4. Choose Settings
  5. In the left hand part of the Settings window, click: Shared Folders
  6. In the right hand part of the Settings window, click: Machine Folders and choose: Add Shared Folder
  7. In the Add Share window, in the field

    Folder Path
    

    use the browse facility (the “drop down arrow”) to choose the relevant folder found in item 1.

    The field

    Folder Name
    

    is the name of the shared folder as seen from the virtual machine. (Automatically filled in, using the last part of Folder Path)

    Make sure the field:

    Auto-mount
    

    is selected, then the shared folder is automatically added to the VM file system.

  8. Press OK to save the created share.

  9. Press OK in the Settings window
  10. If the VM is already running, restart it now. Otherwise start the VM.
  11. Once the VM has booted. Double click the Shared folders icon. The shared folder will be named sf_<folder name> where <folder name> is the folder name chosen above. Double click and verify that it is correct.

    You can also verify the other way. In the sf_<folder name> folder. Right click on an empty area, ask it to create a new text file. Just leave it empty. Then verify from the Host that you can see this file.

Dealing with a Danish Mac keyboard

As you can see on the image below the $ is placed differently and for non-Mac users the \, []'s, {}'s and @ are given by Alt+Shift+7, Alt+8, Alt+9, Alt+Shift+8, Alt+Shift+9 and Alt+'

Danish Mac keyboard

Most Linux keyboard setups does not work that well with a Danish Mac keyboard layout. One solution is to switch to a US keyboard layout (in a DK VM: Menu -> Instillinger -> Tastatur-inputmetoder, switch to the Inputmetode tab, mark Tilpas aktive indlæsningsmetoder to activate the interface, in Væld en inddatametode choose Engelsk -> English (US)), then $, \, [], {} and @ can easily be found by trail and error.

However, we would of course rather want the normal Mac combinations to work in the VM.

  1. From the VM, download Xmodmap_lubuntu_mac (or copy it to the VM via the shared folder).
  2. Make sure the file is at the root of the sas user (not on the Desktop (Skrivebord) or in the Downloads folder (Overførsler)).
  3. We will make a short cut (Linux term: softlink) to this file

    • Open a terminal (Systemværktøjer -> Xterm)
    • First verify that the file is at the root (execute each line at a time):

      cd
      ls Xmodmap_lubuntu_mac
      

      If it replies that it cannot find the file, make sure to move Xmodmap_lubuntu_mac to the root, you can use the file manager.

    • Make the short cut

      ln -s Xmodmap_lubuntu_mac .Xmodmap
      

      Here it is very important to remember the dot at the start of the .Xmodmap, this indicates that we are creating a (hidden) configuration file.

    • Reboot the VM
      Technically we only need to log out and in again (but then we have to remember the password for the VM, and by rebooting it we do not need to)

You should now have

7 8 9 $ '
Normal 7 8 9 $ '
Shift+ / ( ) *
Left-Alt+ \ [ ] @
Left-Alt+Shift+ { }

A note on using the SAS VM

Here are a few things we have noticed when students have used the SAS VM

  1. Even if you are installing vis USB (StatLab), you will still need approx. 13Gb of free space on the harddrive for SAS and operating system. Many students struggled with this requirement on the low range MACbooks.
  2. On low powered hots, it is a good idea to change SAS to not use a browser to show output, but resort back to SAS only. To do this use

    Tools → Options → Preferences... → Results

    Enable Create listing and explicitly disable Create HTML.

  3. If you are using a MAC host, remember that the MAC command key has no meaning in the VM. It uses CTRL-c etc for copying.

  4. In SAS CTRL-v, for pasting in the SAS program editor does not seem to work, use Edit → Paste instead.
  5. Many short cut menus one would get by right clicking inside SAS windows does not work. Use the menus on that window instead.