SAS for Linux
SAS is a general purpose, commercial statistical package and high level data management programming language from the SAS Institute in Cary, North Carolina. SAS is widely used in academia and industry.
Availability
SAS for Linux, Version 9.2 is available on compute server paradigm. SAS Version 9.1.3, Service Pack 4 is available on server verstehen. A Sociology Linux account is required for use.
Access Requirements
Windows users need the following:
PC X-Window server software - we recommend X-Win32, distributed by OIT. Version 9 or above should be used.
An SSH client - we recommend F-Secure, distributed by OIT. When installing this product, make sure that X11 connections are tunneled.
Prior to opening a SAS session:
- Load X-Win32. This makes X-Window services available on your PC.
- Load F-Secure and open a termnal session to paradigm.soc.duke.edu or verstehen.soc.duke.edu.
Mac or Linux users:
SSH and X-Windows are native to these platforms. In either case, open a terminal window and start an SSH session to verstehen or paradigm including the -Y option, which ensures proper operation of SAS in GUI mode. The following example is correct when your Mac or Linux userid matches your Sociology userid.
$ ssh -Y paradigm.soc.duke.edu
- When the ids differ, the Linux userid must be included in the login specification as illustrated below:
$ ssh -Y abc12@paradigm.soc.duke.edu
Invoking SAS and Submitting Programs
SAS may be run in interactive or batch mode. When learning SAS, interactive mode is preferrable. Experienced SAS users often come to prefer batch mode, especially for complex programs that require hours or days to complete.
Interactive Mode SAS
To invoke interactive SAS, change to the directory in which you wish to work and type:
sas &
The SAS splash screen appears momentarily followed by five windows:
Toolbox - with icons for commonly performed actions
Explorer - with links to various parts of the SAS environment
Program Editor - where SAS code is written and submitted
Log - where the results of executed SAS code are displayed
Output - where the results of SAS procedures are displayed
Placement of the ampersand (&) after the command returns the command prompt, so that your terminal window can be used for other activity.
The default program editor under Linux SAS is quite different than that of Windows SAS, but it can be reconfigured to behave like the Windows editor. The steps in doing this are described in ["Reconfiguring the SAS Program Editor Under Linux"].
Important Note Regarding Keyboard Behavior: When access is through X-Win32 and an SSH client under Windows, make sure that the NumLock key is toggled off. When enabled the Backspace and Delete keys do not work in the SAS Program Editor.
Batch Mode SAS
Batch mode SAS requires preparation of your SAS program in an editor such as emacs or pico (see ["Linux Editing"]) or your preferred editor under Windows. Then the program is submitted to SAS from the Linux command line. Assume, for example, you have created a program called recodes.sas. [Use of the .sas filename extension is the convention for naming a SAS program.]
To submit this program in batch mode, type:
sas recodes.sas &
SAS executes the program in the background and writes to the current directory corresponding log and output files named in tandum with the program file. In this example, the files would be called recodes.log and recodes.lst.
The results of batch execution are conveniently viewed with the less paging command:
less recodes.log
The less utility allows you to quickly page through log and output files. Navigation involves simple keystrokes:
spacebar - to scroll to the next screen
b - to scroll back a screen
q - to quit
/pattern - to search forward for an instance of pattern [when found is displayed in reverse video]
/ - to repeat forward search
?pattern - to search backward for an instance of pattern
? - to repeat backward search
General Guideline
Always examine your SAS log carefully, as it contains notes, warnings and error messages that allow you to verify correct program execution or to diagnose problems in syntax or logic. Interactive SAS messages are color-coded: notes in blue, warnings in green and errors in red.
Getting Help
SAS provides documentation through searchable, online tools and through detailed manuals available as downloadable PDF files. The table below organizes some of the more useful documentation links for the 9.1.3 release. The online documentation is quickly searched and provides focused information. The PDFs are more detailed and broader in scope. SAS documentation applies to Windows and Linux unless otherwise noted.
Topic |
URL |
SAS OnlineDoc 9.1.3 <<BR> Recommend this be bookmarked |
|
Base SAS 9.1.3 |
http://support.sas.com/documentation/onlinedoc/base/index3.html |
SAS 9.1 Documentation |
http://support.sas.com/documentation/onlinedoc/91pdf/index.html |
Printing
Interactive SAS for Linux printing is normally done from the log and output windows. Simply select the File > Print option in these windows. The first time this is done following SAS: Print... dialog box appears:
- attachment:sas_print1.png
Select the Use Forms option at the top of the box. The window transforms to the following:
Select OK to print the item and save this setup.
The default form printing is pre-defined for 2-up printing (two sheets per page) with the enscript printing utility. Note, in the second box of this dialog that the default printer is set to copy2 (the network printer located in the second floor copy room). If you prefer to print to the Room 135 lab, just replace copy2 with lab.
SAS batch output is printed from the command line. Assuming the example SAS job recodes.sas produces log and output files named recodes.log and recodes.lst, they are printed to the default Linux printer (copy2) with the command:
enscript -2rG recodes.log recodes.lst
Sending to the alternate lab printer, just requires a printer specification:
enscript -Plab -2rG recodes.log recodes.lst
For a more in-depth discussion of handling output see Handling SAS Output Under Linux.
Sociology domain users who store Linux SAS programs, outputs and data sets under their lanhome directory have them directly available under Windows when that directory is mapped to a drive letter. So outputs may be viewed, printed or otherwise used from Windows.

