Contents of This Page
- Introduction
- Using SAS With Your IFS Home Directory
- Three Modes for Running SAS
- Noninteractive
Mode
- A Sample SAS Session in Noninteractive
Mode
- Example of Running SAS in Noninteractive
Mode
- Interactive
Line Mode
- Example of Running SAS in Interactive
Line Mode
- Display
Manager Mode
- Starting the X Window System Software
- Connecting to the Statistics Service
- Setting the Display to Your Local Machine
- Starting SAS
- The Basic Windows
- Program Editor
- Log
- Output
- A
"Short" List of SAS Manuals
- Getting Help With
SAS
- Consulting
- Documentation
Introduction
SAS is one of the statistical programs
provided through the Statistics Service. SAS has
a variety of routines that make it a powerful and
flexible tool not only for statistical analysis,
but also for data management, graphical displays,
and many other types of tasks.
Using SAS With Your IFS Home Directory
Many users of SAS will be using SAS from their
IFS (Institutional File System) home directory.
For example, the IFS home directory for an
individual with the uniqname bjensen would be
/afs/umich.edu/users/b/j/bjensen.
There is a minor bug in SAS6.09 when used with
a home directory which resides in IFS/AFS. Some
users may receive a warning about failing to read
the SASUSER.PROFILE.CATALOG. This is being
investigated by SAS Technical Support. A
workaround for the time being is to do the
following when invoking SAS:
- Make a directory on
/tmp,
which is a local directory on the
Statistics Service
Invoke SAS with the -sasuser option
specified, so that certain temporary
files will be written to the /tmp/$user
directory, rather than the IFS home
directory.
You would type the following commands at the
Unix prompt, where $user would be your uniqname:
- mkdir /tmp/$user
- sas -sasuser /tmp/$user
For example, bjensen could invoke SAS with the
following commands:
- mkdir /tmp/bjensen
- sas -sasuser /tmp/bjensen
Other options or a command file could also be
specified when invoking SAS, as discussed below.
Three Modes for Running SAS
There are many ways to run SAS on Unix. This
document will discuss three modes for running
SAS:
- Noninteractive mode
- Interactive line mode
- Display manager mode
Noninteractive Mode
Noninteractive mode is one way to run SAS on
Unix that does not require a special connection
(like Ethernet), or a graphical interface. If you
are used to connecting to MTS via PROCOMM PLUS,
or VersaTerm, or PCTIE, this mode will be very
easy to use. The advantage of using
noninteractive mode is that it is widely
accessible: in this mode, you can use SAS from
anywhere that you can connect (at home, or at the
office) and you can use it with only a modem
connection. The disadvantage is that high
resolution graphics are not possible when using
this mode of accessing SAS.
SAS in noninteractive mode is run by creating
a command file and issuing the SAS command from
within Unix as shown below:
sas [your command file] [list of
options]
Note that "sas" is given in lower
case letters. This is to conform to the Unix SAS
convention. If, for example, your command file
were called test.sas, the command to run it would
be:
sas test.sas
A list of options may be given to customize
your SAS output or your SAS session. For example,
if you wanted your SAS output to be a width that
is easily readable from the terminal (i.e.
linesize=72), and you did not want the date to be
printed on each page of output, you might run SAS
with the options shown below.
sas test.sas -linesize 72 -nodate
When SAS is run in noninteractive mode, there
will be no messages, or other indication that the
program is running. You will simply notice that
the Unix prompt will be gone for a period of time
that will vary according to the size of the
program that you are running, and the number of
other users and the size of their jobs. When your
SAS job has completed, you will again see the
Unix prompt, and will be able to do other tasks.
If you wish to run SAS in the background, and
be able to do other tasks while SAS is running,
you may give the command:
sas test.sas &
SAS in noninteractive mode usually creates two
files when it is run. The first is a log file
that contains a listing of your SAS commands,
along with any notes or errors from SAS. This
file is essential for troubleshooting, and is
where you would look if you have difficulty with
a particular program that you are running. If
your command file were named test.sas, as in the
example above, the log file would be called
test.log. If you wanted to view the contents of
test.log, you could issue the Unix command:
more test.log
This will display the contents of test.log one
screen at a time so that you may browse its
contents. When you want the screen to advance,
simply press the space bar to advance the file
display by one screen, or press Return to advance
the file display by one line. If you wish to stop
the screen display at any point, type
"q" and you will be returned to Unix.
Depending on the commands that you have given
SAS, it may also create an output file. This file
will contain the output from any procedures that
you have run in SAS. If your command file were
called test.sas, the output file would be called
test.lst. To view the contents of the file
test.lst, give the following Unix command:
more test.lst
A Sample SAS Session in Noninteractive Mode
For this example, we will assume that you have
created a command file called test.sas. The
command file shown below tells SAS to create a
temporary data set called test, containing the
variables SUBJECT (which is a character, or
string variable, as indicated by the $ sign after
the variable SUBJECT), AGE, GROUP AND SBP
(systolic blood pressure). A listing of the data
set test is then obtained from SAS by using the
SAS procedure, proc print. A listing of test.sas
is shown below:
data test;
length subject $ 10;
input subject $ age group sbp;
cards;
Michael 22 1 128
Greg 28 1 137
Alicia 26 1 143
Shana 25 1 119
Bobby 27 2 133
Melody 24 2 146
Hank 28 2 140
Cassie 37 2 137
;
proc print;
title 'printout of data for
test data set';
run;
This command file could be run on Unix SAS and
the output viewed by giving the following
sequence of commands:
sas test.sas -linesize 72 -nodate
ls -l test*
more test.lst
more test.log
The command "ls -l test*" is a Unix
command that is run when the SAS run is
completed. It tells Unix to give a listing of all
files that begin with "test" and have
any ending (the wild card "*" is used).
This will let you know if your log and output
files have been created. The log and output files
are then viewed with the "more"
command. In general, it is wise to check which
files have been created after a SAS run. If your
commands were not completely executed because of
errors in the command file, an output (.lst) file
may not have been created. However, the log
(.log) file would have been created in any case.
This file may be browsed using the
"more" command to see where the error
occurred.
Example of Running SAS in Noninteractive Mode
Which Host? stat.itd.umich.
edu
%TN05:HME05C-HME05D:TN00 telnet
%Call connected - 141.211.83.52
Unix(r) System V Release 4.0
(robotron.rs.itd.umich.edu)
login: bjensen
Password:
AFS (R) 3.3 Login
Last login: Thu May 5 13:14:40 from
hme0.merit.edu
TERM = (vt100)
>
robotron% sas
test.sas -linesize 72 -nodate
robotron% ls
-l test*
-rw-r--r-- 1 bjensen 2394 May 5
13:23 test.log
-rw-r--r-- 1 bjensen 570 May 5
13:23 test.lst
-rw-r--r-- 1 bjensen 336 May 5
13:15 test.sas
robotron%more
test.lst
printout of data for test
data set 1
OBS SUBJECT AGE GROUP SBP
1 Michael 22 1 128
2 Greg 28 1 137
3 Alicia 26 1 143
4 Shana 25 1 119
5 Bobby 27 2 133
6 Melody 24 2 146
7 Hank 28 2 140
8 Cassie 37 2 137
robotron%more
test.log
NOTE: AUTOEXEC processing
beginning; file is
/afs/umich.edu/group/itd/software/packages/s
/s01 secondsn4m_53/autoexec.sas.
NOTE: SAS initialization used:
real time 3.01 seconds
cpu time 1.61 seconds
NOTE: AUTOEXEC processing
completed.
1 data test;
2 length subject $ 10;
3 input subject $ age group sbp;
4 cards;
NOTE: The data set WORK.TEST has 8
observations and 4 variables.
NOTE: DATA statement used:
real time 0.48 seconds
cpu time 0.27 seconds
13 ;
14 proc print;
15 title 'printout of data for test
data set';
16 run;
NOTE: The PROCEDURE PRINT printed
page 1.
NOTE: PROCEDURE PRINT used:
real time 0.54 seconds
cpu time 0.31 seconds
17
NOTE: The SAS System used:
real time 4.20 seconds
cpu time 2.45 seconds
robotron%
If your raw data were in a separate file, you
could create a command file similar to the one
shown below. The Unix command "more" is
used to view the command file test2.sas. Note
that the infile statement points to the raw data
file test.dat, which is listed after the command
file, again, using the Unix "more"
command.
robotron% more
test2.sas
data test;
length subject $ 10;
infile 'test.dat';
input subject $ age group sbp;
proc print;
title 'printout of data for test
data set';
run;
robotron% more
test.dat
Michael 22 1 128
Greg 28 1 137
Alicia 26 1 143
Shana 25 1 119
Bobby 27 2 133
Melody 24 2 146
Hank 28 2 140
Cassie 37 2 137
robotron%
The command file test2.sas could be run in
Unix by issuing the following commands:
sas test2.sas -linesize 72
For more information about running SAS in
noninteractive mode, see SAS Companion for
Unix Environments: Language, Version 6,
First Edition.
Interactive Line Mode
Interactive line mode is another method for
running SAS if you do not have a terminal screen
that will support graphics output. It may also be
used on a graphics terminal screen, if you do not
desire to run SAS in display manager mode. This
method of running SAS allows you to submit
command files via the %include command, or to
enter commands manually, one line at a time. In
interactive line mode, the SAS log and output
will all appear on the screen, one line at a
time. To invoke SAS in interactive mode, you may
issue the Unix command:
sas -nodms [list of options]
The -nodms option states that you do not want
to run SAS in data manager mode. If you wanted to
run your command file, test.sas via interactive
line mode, you could issue the following command
in Unix:
sas -nodms -linesize 72
The command "sas -nodms" invokes SAS
in interactive line mode. Once SAS is invoked in
this mode, you will see some information from SAS
on your screen. Then, you will see a linenumber
prompt from SAS:
1?
at this point, you may enter SAS commands one
line at a time, or submit a command file by using
the %include statement. For example to submit
test.sas, you would type
%include 'test.sas';
after a linenumber prompt.
When you are finished with your SAS session,
you may exit SAS by typing the command
"endsas;" at a linenumber prompt.
Example of Running SAS in Interactive Line
Mode
Which Host?stat.itd.umich.edu
%TN05:HME05C-HME05D:TN00 telnet
%Call connected - 141.211.83.52
Unix(r) System V Release 4.0
(robotron.rs.itd.umich.edu)
login:bjensen
Password:
AFS (R) 3.3 Login
Last login: Thu May 5 13:14:40 from
hme0.merit.edu
TERM =(vt100)
robotron%sas
-nodms -linesize 72
NOTE: AUTOEXEC processing
beginning; file is
/afs/umich.edu/group/itd/software/packages/s
/sas-6.09/sun4m_53/autoexec.sas.
NOTE: SAS initialization used:
real time 1.73 seconds
cpu time 1.63 seconds
NOTE: AUTOEXEC processing
completed.
1? %include
'test.sas';1
%include 'test.sas';
NOTE: The data set WORK.TEST has 8
observations and 4 variables.
NOTE: DATA statement used:
real time 1.17 seconds
cpu time 0.30 seconds
printout of data for test data set
1
13:35 Thursday, May 5, 1994
OBS SUBJECT AGE GROUP SBP
1 Michael 22 1 128
2 Greg 28 1 137
3 Alicia 26 1 143
4 Shana 25 1 119
5 Bobby 27 2 133
6 Melody 24 2 146
7 Hank 28 2 140
8 Cassie 37 2 137
NOTE: PROCEDURE PRINT used:
real time 0.26 seconds
cpu time 0.23 seconds
19? proc means
data=test;
19 proc means data=test;
20? run;
20 run;
printout of data for test data set
2
13:35 Thursday, May 5, 1994
Var N Mean Std Dev Minimum Maximum
---------------------------------------------------------
AGE 8 27.1250000 4.4860896
22.0000000 37.0000000
GROUP 8 1.5000000 0.5345225
1.0000000 2.0000000
SBP 8 135.3750000 8.6674679
119.0000000 146.0000000
---------------------------------------------------------
NOTE: PROCEDURE MEANS used:
real time 2.63 seconds
cpu time 0.17 seconds
21? endsas;
21 endsas;
NOTE: The SAS System used:
real time 43.62 seconds
cpu time 2.76 seconds
robotron%
For more information about running SAS in
interactive line mode, see SAS Companion
for Unix Environments: Language, Version
6, First Edition.
Display Manager Mode
for WindowsYou can run SAS in display manager mode if you
have a terminal that is capable of displaying X
Window System output. This mode of running SAS
allows you to have windows with pull down menus,
to have high quaCgraphics, and to scroll
through your commands, log and output. It is much
more memory intensive than either of the previous
two methods for running SAS, and is not
recommended if you have large jobs to run.
You may use SAS with the X Window System and
Display Manager Mode if your local machine is an
X terminal, or a Unix workstation, or if you have
X server software on your PC.
Some examples of X server software for the PC
are Xoftware by AGE Logic, or eXceed, by
Hummingbird. In order to use X Window
System displays on your local computer, it will
be necessary for you to be connected to the
network via Ethernet, or some other method that
is capable of transmitting large amounts of data
very quickly, and producing graphics displays on
your local machine.
To run SAS in Display Manager Mode, with the X
Window System, there are four steps involved:
- Start the X Window System server software
- Connect to the Statistics Service
- Set the display to be sent to your local
machine
- Start SAS
Display Manager Mode
for Macintosh
To run SAS in Display Manager Mode, Mac OS X
users should:
1) Install X11 for Mac OS X (a custom
install from your OS X software discs), if it is
not already installed.
2) Start X11 (installed under
Applications>Utilities>X11)
3) In X11, open a new Terminal window from the
Applications pulldown menu. (This terminal
window must be opened with X11, and not with the
simpler "Terminal" program also installed in the
Utilities folder.)
4) At the % prompt, type
% ssh -X uniquename@scs.itd.umich.edu
% password
% sas
For a good, concise explanation of X11, refer to
http://www.scl.utah.edu/computers/mac/help/x11/.
Starting the X Window System Software
Whatever local machine you are using, you must
first start up your local X server software. If
you are using a Unix machine locally, the X
server software may be already activated when you
log in. If not, ask someone how to start it on
your machine. If you are using a PC with Windows,
you will want to start your X server software
(e.g. double click on the Xoftware or eXceed
icon).
Connecting to the Statistics Service
Next, you must telnet to the Statistics
Service. This can be done with a telnet command
(from a Unix workstation), or may be done with
the LAN WorkPlace for DOS Host Presenter software
from a PC with Windows. (Open Windows, double
click on the LAN WorkPlace icon, and once it is
open, double click on the Host Presenter icon,
then open the host
"stat.itd.umich.edu").
Setting the Display to Your Local Machine
Once you are connected to the Statistics
Service, you must tell the machine to which you
are connected that you wish to have your SAS
display sent to your local machine. This can be
done by giving the following command in Unix:
setenv DISPLAY [local
ipaddress/machinename:0]
For example, if your local machine is named
grumpy.cscar.umich.edu, you would issue the
following commands:
setenv DISPLAY
grumpy.cscar.umich.edu:0
The :0 is part of the DISPLAY
environment that is necessary to tell Unix where
to locate the graphics (X Window System display)
on your screen.
(Please note that with
Mac OS X you do not have
to do anything to set the display to your local
machine, as X11 does this automatically for
you.)
Starting SAS
Once you have done the previous steps, you can
invoke SAS with the following command in Unix:
- sas [list of options]
You may give options to customize your SAS
session when you invoke SAS. If you have
everything set up properly, SAS will begin
executing, and after a few seconds you will see
three windows appear on your screen:
- Program Editor
- Log
- Output
Program Editor
The Program Editor window is actually an
editor that can be used to create and modify SAS
command files. The Program Editor window has
several pull-down menus along the top of it. They
are File, Edit, View, Locals, Globals and Help.
The File menu is used for opening, saving and
printing files (text files only, not SAS data
sets!). It is also the menu used to Exit from
SAS. The Edit menu can be used to clear the
Program Editor, or to do other editing tasks. The
Locals menu is used to submit commands and to
recall previously submitted commands. The Globals
menu is used to get around from window to window,
and also to execute other SAS procedures, like
SAS Assist.
When you are in the Program Editor, you may
edit and change files, or create new files. After
your command file is set up the way you want it
to be, simply go to the Locals menu and choose
Submit. This will send the commands in the
Program Editor to SAS to be processed.
Log
The Log window contains any messages that the
Unix administrator wants you to read, and a log
of all your commands, and any error messages from
SAS.
After submitting a SAS command file, it is
always wise to check the Log for any possible
errors that may have occurred. Even if there are
no problems with your program, there is valuable
information in the Log, such as the number of
observations and number of variables in any data
set that you may have created. It is always good
to check these things to make sure that the data
set is as you expected it to be.
Output
The Output window contains the output from any
SAS commands that you have submitted. You can
control the appearance of the output by using SAS
options, like linesize and pagesize. Once you
have checked your output to be sure that it looks
correct, you may wish to save your output to a
file. The file may then be printed at a later
time.
A "Short" List of
SAS Manuals
A very large library of SAS manuals is
available for ordering from the
SAS Institute. Some
of these manuals are also available from Photo
and Campus Services (764-9216) in the basement of
the LSA Building. In addition to those listed
below are many manuals for specific SAS products,
as well as technical reports. A full listing of
publications is in the SAS Publicatons Catalog,
available from SAS Institute. Their phone number
is 919-677-8000. Ask for Book Sales. An annotated
list of some SAS manuals is given below.
SAS Language and Procedures:
Introduction, Version 6, First Edition.
This small but very useful guide provides a good
basic introduction to SAS, and gives a tutorial.
It is highly recommended for new SAS users.
SAS Language and Procedures: Usage,
Version 6, First Edition and
SAS Language and Procedures: Usage II,
Version 6, First Edition. These two thick volumes
are very useful for new SAS users, since they
give many examples of how to do specific tasks.
SAS Language: Reference, Version
6, First Edition. This is the basic reference
guide for SAS, and is essential for serious users
of SAS. It provides the most complete information
on the base SAS software, and includes
information on reading external files, formatting
data, data transformations and merging data sets,
among other things.
SAS Procedures Guide, Version 6,
First Edition. This manual provides syntax for
the base SAS procedures, including proc contents,
proc copy, proc freq, proc means, and many
others.
SAS Companion for Unix Environments:
Language, version 6, First Edition, 1993.
This guide is essential for Unix SAS users, and
you should have access to it when using SAS on
Unix. It gives information on how to access
external files, how to use SAS with data sets
from other statistical programs, such as OSIRIS,
BMDP and SPSS, and how to read and create SAS
transport files on the Unix platform, along with
much other useful information.
SAS Companion for Unix Environments:
User Interfaces, Version 6, First Edition,
1993. This guide gives specific information on
customizing your SAS interface for the specific
environment from which you are running SAS. This
guide is appropriate for more advanced Unix and
SAS users.
SAS Applications Guide, 1987
Edition. This guide is extremely useful for
anyone wanting to do data management tasks using
SAS. It gives practical examples for recoding
data, merging data sets, reading hierarchical
data, and reshaping data to make variables into
observations and to make observations into
variables. It carries a lot of information in a
small package.
SAS System for Elementary Statistical
Analysis, 1987. This small volume gives
step-by-step illustrations on how to do
elementary statistical analysis using SAS. It
covers univariate statistics, t-tests, anova,
regression and simple plots, among other things.
Highly recommended for new users of SAS for
statistics.
SAS/STAT User's Guide, Volumes 1
and 2, Version 6, Fourth Edition. These guides
are essential for running SAS to do traditional
types of statistical analysis, including ols
regression, anova, factor analysis, logistic
regression, nonparametric tests, etc. They give
the syntax, options and examples of each
procedure.
SAS Technical Report P-229. SAS/STAT
Software: Changes and Enhancements,
Release 6.07, 1992. This manual updates the SAS/STAT
User's Guides to include enhancements to
various statistical procedures. Information is
also included on some new procedures, including
Proc Mixed, a procedure for analyzing mixed
models anova (unbalanced random effects models)
and models with various covariance structures.
Proc Phreg is also included for Cox model
survival analysis.
SAS/ETS User's Guide, Version 6,
Second Edition. This guide gives information on
the ETS (Econometric Time Series) procedure. It
includes information on arima models, systems of
linear equations, and systems of nonlinear
equations, as well as time series cross-sectional
studies.
SAS/ETS Software: Applications,
Guide 1 and Guide 2, version 6, first edition.
These two guides give practical examples of how
to carry out various types of models using ETS
(Econometric Time Series). Very useful for those
doing econometric modeling.
SAS/IML Software: Usage and Reference,
Version 6, First Edition. This guide documents
the SAS IML (Interactive Matrix Language)
procedure. This extremely powerful procedure
allows users to manipulate matrices, rather than
working only with individual variables. This
facility allows users to build their own
statistical procedures, do simulations, etc.
SAS Technical Report P-230, SAS/IML
Software: Changes and Enhancements, Release 6.07.
This volume documents updates to IML, including
new built-in functions to do numerical
integration, and solve ordinary differential
equations. It also documents the library of
built-in modules written in the IML language.
SAS System for Linear Models, 3rd
Edition, 1991. This handy guide gives
explanations and examples for working with linear
models (regression and anova) using SAS.
SAS Graph Software: Introduction,
Version 6, First Edition, 1990. This small
introductory guide is very useful for new users
of SAS Graph. It gives information on how to
produce simple graphs, and send the output to the
screen, a printer or a file.
SAS/Graph Software: Usage,
Version 6, First Edition. This manual provides
illustrations of many common graphing tasks. A
good manual for non-experienced SAS Graph users.
SAS/GRAPH Software: Reference,
Volumes 1 and 2, Version 6, first edition, 1990.
These two thick volumes give the syntax for SAS
Graph and are the most complete resource for this
procedure. Volume 1 gives information on how to
produce titles, footnotes, legends, annotation in
graphs, etc. Volume 2 gives information on
specific procedures. These are only recommended
for serious SAS Graph users.
SAS Guide to Macro Processing,
Version 6, Second Edition. This guide gives
information on how to do macro processing using
SAS. It is essential for anyone wishing to set up
macros to do repeated or complex procedures in
SAS.
Getting Help With SAS
Consulting
CSCAR
consultants provide technical assistance on the
use of a variety of statistical software
packages, including SAS. They are also available
to assist researchers with statistical
methodology issues. The CSCAR consultants can be
reached via email,
telephone or personal visit. All persons
engaged in scientific research, including staff,
faculty and graduate students, are are encouraged
to contact the CSCAR with their questions!
Additionally, the CSCAR offers the informal statistical
workshop series, "Continuing Training to
Facilitate Quantitative Research." Sessions
covering the use of statistical software
packages, including SAS, and seminars on the use
of statistics in research and industry are
offered.
ITCS consultants provide general computer
assistance at 764-HELP; School
of Education and Angell Hall
Courtyard computing sites; and via e-mail
(online.consulting@umich.edu). For more
information on consulting please
visit
http://www.itd.umich.edu/help/over.consultant.html.
Additional information about
documentation, workshops, and
other services can be found at
http://www.itcs.umich.edu.
Documentation
ITCS no
longer provides SAS
documentation, but information
on general ITCS documentation
can be found at this page:
http://www.itcs.umich.edu/itcsdocs/
|