![]() |
Information
Technology Services Centre |
1. Introduction
SAS is a computer package for data analysis. It provides tools need for information storage and retrieval, data modification and programming, report writing, statistical analysis, file handling and data presentation.
The SAS for UNIX Version 9.12 is available on the Data Library and Academic Applications Software Server (Theory). The following SAS products are available: SAS/AF, SAS/ASSIST, SAS/BASE, SAS/ETS, SAS/FSP, SAS/GRAPH, SAS/IML, SAS/INSIGHT, SAS/OR, SAS/STAT, SAS/Enterprise Miner Server Solution and SAS/SHARE.
2. Access to SAS on 'Logic'
'Logic' is accessible via ssh at logic.itsc.cuhk.edu.hk. Refer to ITSC Quick Start Guide WKS003 Use of Gemeral-purpose UNIX Server (Logic) for the access details. After successful connection,
The method of access to SAS described in section 2 will invoke SAS in an interactive mode. After invoking SAS, three windows will be opened, one is the LOG window (used to display SAS messages), another one is the PROGRAM EDITOR window (used to enter and submit SAS programs) and the last window is the OUTPUT window (contains SAS procedure outputs).
Please note that the text interactive mode no longer exists in Version 9. If you need to run you SAS job interactively, you must use X-window interface.
3.1 Basic Interactive SAS Commands under X-windows Environment
| X-windows | |
| submit
a program |
|
| exit from SAS |
|
| save a SAS program to a file |
|
| get a SAS program |
|
| get HELP |
|
| invoke SAS/ASSIST software |
|
A SAS sample program can be found in 4.1.
4. Running SAS as a Background Process
Running SAS as a background process allows you to work on other tasks at your terminal when SAS is processing your program. The simplest way is to create a file containing your SAS statements and execute the shell command 'sas' as a background process (using an & at the end of the command line). The general format of running SAS programs in background is as shown below:
[theory]% sas user_file [-option1 ... -option-n] &where
|
user_file |
gives the name of the file containing the SAS program to be executed. In a background process, SAS will create two files. One is for the SAS log message (user_file.log) and the other is for the SAS procedure output (user_file.lst). |
|
-option |
specifies SAS system option(s) to configure your session. There are over 100 system options that can be specified. See Chapter 8 "SAS System Options" of the SAS Manual, SAS Companion for the UNIX Environment and Derivatives for information on system options. |
4.1 Example
The following SAS program is saved as sample.sas:
|
data test; input name $ 1-30 score1 31-32 score2 33-34; cards; Mr. Chan Tai Man 1223 Mr. Hui Lap Yan 8967 Miss Chan Sai Fun 8765 Mrs. Wan Wan Ling 8987 ; proc print; proc univariate; var score1 score2; run; |
You can run the program interactively as described in section 3 or submit it as background progress by command,
[theory]% sas sample.sas -nodate -linesize 80 &Where the options "nodate" means not to output the date and time information on the output and "linesize 80" means setting the output length to 80 columns. By default, the output filename is the same as your input filename but with extension .lst . In the above example, the output filename is sample.lst
The execution of the program will abnormally terminate if the user logout before the program finished. In order to prevent this, you can type the following:
[theory]% nohupsas my_prog.sas &5. Data Files Handling In SAS
You begin with raw data, that is, a collection of data that have not yet been processed by the SAS system. You use a set of statements known as a SAS DATA step to get your data into a SAS data set. Then you can further process your data with additional DATA step programming or with SAS procedures.
Raw Data --> DATA Step --> SAS data set --> PROC steps -> Results of Analysis
|
LIBNAME
|
libref 'your-SAS-data-library'; associate a libref with a SAS data library. Enclose the name of the library in quotes. The SAS System locates a permanent SAS data set by matching the libref in a two-level SAS data set name with the library associated with that libref in a LIBNAME statement. In UNIX, a SAS data library is a directory. |
|
DATA |
[libref.]SAS-data-set; tells the SAS System to begin creating a SAS data set. If you give just an SAS-data-set, the SAS System creates a temporary SAS data set. |
|
INPUT |
variable[$]; reads raw data using list input. At least one blank must occur between any two data value. The $ denotes a character variable. |
|
INPUT |
variable informats; reads raw data using formatted input. An informat supplies special instructions for reading the data. |
|
INFILE |
fileref | 'your-input-file'; identifies an external file to be read by an INPUT statement. Specify a fileref that has been assigned in a FILENAME statement or the actual name of the external file. |
|
FILENAME |
fileref 'your-input-file' associates a fileref with an external file. Enclose the name of the external file in quotes. |
6. New Features
This release has Web Enablement Tools and new graphic format support. It can be read on-line at http://www.sas.com/rnd/web.
7. References
7.1 Manuals
7.2 Others
For any enquiries, please contact us by:
Website: http://www.cuhk.edu.hk/itsc
Electronic HelpDesk: https://helpdesk.itsc.cuhk.edu.hk/group/sas-help
Fax: 2603-6946
Phone: 2609-8845 (Hotline Services)
Monday - Thursday 08:45-13:00 14:00-17:30
Friday 08:45-13:00 14:00-17:45
Saturday, Sunday & Public Holiday close