Table of Contents

SAS Libraries
Other files for SAS
SAS autoexec files
SAS execution modes
SAS Display Manager


Since August, 2001, the production version of SAS for Unix at the University of Manitoba Academic Computing and Networking (ACN) has been release 8.2.

SAS 6.12 was removed from the Unix system in November, 2001, when the license for it expired.

Online documentation for Version 8 is available on our Web site in plain html and Java-enabled versions. Due to licensing restrictions, these web pages are made available only to computers with recognized University of Manitoba IP addresses. This includes users dialling in from home to the University of Manitoba modem pool.

In addition printed manuals from the SAS Institute are available in ACN, for more information contact Nick Donaldson.

The SAS software package is available on all of the Sun workstations and login servers owned by ACN. However, you do not have to be working from the console of one of these machines to use SAS, as they all support remote login and telnet access.

You can use the Unix commands machines -b or rup machine-name to find out which of the workstations and login servers is the least busy. High load average numbers indicate high activity.

Hardcopy plotting support for SAS is provided through the Campus Copy Center (copyctr). SAS generates postscript which may be directed to the Copy Centre laser printers in University Centre. Laser printing is a charged service. Invoices are sent monthly by e-mail to account owners who have used charged services such as laser printing or dial-in modem time.

For more information on printing, try how to print to the copy center from Unix.

SAS Libraries

SAS allows you to create SAS data sets, SAS data views and various sorts of SAS catalogues, which are stored in SAS libraries. It is recommended that you use a Unix directory for each SAS library. Normally all data sets and catalogues related to a particular project would be stored in the same library. We recommend that you keep related text files in a separate directory from the SAS library.

To create a directory for use as a SAS library, use the Unix mkdir command. For example to make a library directory called saslib1:

    mkdir saslib1  

To be sure that SAS will find the correct directory, it is best to use the fully qualified Unix path name in your SAS libname statement. You can use the Unix "pwd" command to identify the full path of the file. The libname statement used to identify the directory would look like:

    libname lib1 '~myid/saslib1';  

Where ~myid is a reference to the root of the directory structure for the account myid, this is called the home directory.

Other files for SAS

SAS allows you to define other files that are not SAS libraries, using the 'filename' statement. The main reason for doing this is to tell SAS where to find a raw data input file, or where to write reports generated by PUT statements in a data step. An interesting feature of SAS filenames under Unix is that you are allowed to use the Unix concept of a "pipe" to have the data generated by a Unix command, or to send the output records to another Unix command.


    filename newdata 'datafiles/oct93';  

This means: "From now on, the file called newdata refers to the file oct93 in the datafiles directory." Since a fully qualified file name was not used, 'datafiles' must be in the same Unix directory from which you invoked SAS.

    filename rawin pipe 'zcat study.Z';  

This means "use a temporary, uncompressed copy of study.Z as file rawin."

    filename report pipe 'lpr -Peng524';  

This means "send file report directly to the "eng524" printer."

SAS autoexec files

When you run SAS under Unix, SAS will try to find an file. First SAS checks your current working directory and if not found continues to check each parent directory back to your home directory. If an file is found then the SAS commands in it are executed at the end of SAS initialization. If there is no file found in this path, SAS will run the installation supplied commands in the file /usr/local/sas611/

An autoexec file is very handy if there are some SAS commands that you issue almost every session, such as OPTION commands or LIBNAME commands. However, if you create your own file, it is recommended that you make the first line:

    %include '!SASROOT/';  

so that any installation supplied commands are also executed. The SAS command %include means 'include this other file of SAS commands to execute'.

SAS execution modes

If you run SAS in batch mode, non-interactive mode, or interactive line mode, the behaviour of the SAS software is largely independent of the hardware that you are using. All that is required is a basic knowledge of the SAS language, and how to manipulate and edit files using operating system commands and an editor. If you are familiar with a Unix text editor, such as "pico" or "vi", you should not have much difficulty running SAS under Unix in these modes.

However, running SAS in Display Manager mode offers more flexibility and help features than the above modes, and can be quite attractive if you have access to a graphical terminal (GUI) from which to launch SAS. Some of the newer products in SAS, such as Spectraview, will only work within the Display Manager. The SAS Program Editor window within the Display Manager provides a text editor which is easier to learn than "vi", and more convenient than "pico" for working on large files.

The basic syntax to run SAS is:

    sas [filename] [-options]  

where filename represents a file of SAS statements to be processed, and -options may be any number of SAS command options.

Batch and Non-Interactive Modes

In batch or non-interactive mode, you use an editor to create a SAS program, then enter a SAS command to execute the file. To run SAS in batch mode (Unix calls it background processing), enter:

    sas filename &  

then SAS will execute your file in the background.

To run in non-interactive mode, leave off the &, and SAS will run in the foreground. That is, your terminal will be locked up until the SAS job completes.

It is customary to name SAS source code files with the extension .sas . The log and listing files produced by a background or foreground SAS program are named with the extensions .log and .lst . For example:

    sas &  

would produce output files sql.log and sql.lst. It is possible to redirect these files, for example:

    sas -log sqllog1 -print results &  

where sqllog1 and results could be any valid Unix file names.

In both of these modes, you will return automatically to your operating system (shell) prompt.

If you are going to be running very long batch jobs in SAS, you should learn about the Unix commands nice and nohup, which will help you to use system resources more effectively and considerately.

Interactive Line Mode

This is much less flexible than the display manager, but can be useful if you can't convince SAS to handle your terminal emulation properly. You can run SAS in interactive line mode by entering:

    sas -nodms  

You then can enter SAS commands for immediate execution, or you can execute SAS code from Unix files by "including" it. For example:

    %include 'sasinput/';  

To exit from SAS in this mode, you need to enter:


at a prompt. Note that the semi-colon is a required command terminator in this mode.

Display Manager Mode

Those who have worked with SAS under DOS, Windows, or Macintosh are likely to be familiar with running SAS in Display Manager Mode. The Display Manager is the default SAS execution mode, if you are working on a device that SAS has defined as a full-screen terminal. The Display Manager Mode is the most convenient mode for learning SAS, for data entry, and for program development.

If you are working at a graphics device (X-windows terminal or emulation), and are connected to a login server that supports SAS, to start the SAS display manager simply enter:

    sas     or     sas &  
The second form will start up the SAS Display Manager, but leave the window where the command was entered available to use for other commands.

To exit, click on "File" in the program editor or log window, then on Exit, or open the SAS session management window, and click on "Terminate".

The SAS display manager expects an X-windows environment.

To exit, enter the command: endsas on a command line, or from the pull down menus, select File, then Exit.

SAS Display Manager under X-windows

Using an X-windows terminal, you would first log in to the terminal's default server.

If the login server to which your X-windows terminal is connected runs SAS, then the "sas" command is all you need to run the display manager within an x-window environment.

In this environment, SAS will start up with pull-down menus, scroll bars, etc., as you would expect from a Windows application. If you prefer to work with the Command line instead of the pull-down menus, the global options selection "action bar off" can be used to turn off the "pmenu" command.

SAS/Graph device drivers for X-windows are XBW, XGRAY and XCOLOR. Additional information about using SAS under X-windows can be found using man sas from your Unix shell prompt.


As the BMDP programs are also available on ACN's Unix login servers, it is possible to execute BMDP code from within a SAS procedure. The following example shows how to run a BMDP procedure using an existing SAS dataset as input. Three external files will be created by this program. They are used to hold temporary copies of the dataset, the BMDP source code, and the BMDP procedure output.

    filename for003   '/tmp/unit003.dat';  filename ft15f001 '/tmp/unit015.dat';  proc bmdp prog=bmdp7d data=sasuser.bmdpdata unit=3;  parmcards;  /input file is '/tmp/unit003.dat'. code is 'bmdpdata'.  /variable names are var1, var2.  /histogram grouping is var1.  variable is var2.  /comparison  /print ttest.  /end  run;  


For bug reports and other related materials, please see the SAS Technical Support Web page at: