SAS ® Statements Used Anywhere

NESUG 15
Beginning Tutorials
SAS ® Statements Used Anywhere
Karin LaPann,
Main Line Contract Services
ABSTRACT
as soon as SAS compiles them, which occurs
from the top down. As all other SAS commands,
they are not case-sensitive.
Whenever programmers are introduced to SAS,
they are taught that there are two kinds of
statements; the PROC step and the DATA step.
However, there is a third group of statements,
which are not procedures, but are essential in the
operation of any SAS code. These are global
statements, or as I call them, statements used
anywhere.
In this paper I offer an in-depth description of the
most common and useful settings for a SAS
session. Additional settings are available and
whenever possible I will point out to the reader
where to find this information in the SAS
manuals. The SAS versions covered in this
paper are SAS 6.12 and SAS 8.1. Currently, the
FDA wants all the data in SAS 6.12, which makes
this a contemporary problem for SAS
programmers working in the pharmaceutical
industry.
Global statements perform the following
functions:
•
Data access
•
Log control
•
Output control
•
Program control
•
Environment control
There are two kinds of syntax for global
statements I will cover in this paper. The first is a
set of statements that begin with a keyword such
as LIBNAME and OPTIONS. The second is a
system option that begins with a %, such as
%INCLUDE and %LET. These statements can
be used almost anywhere, except within a DATA
or a PROC step. (In DATA steps some of these
same features such as libname are offered as
functions instead.)
Understanding and using these global statements
correctly greatly enhances control over the
programming session, and also of the various
SAS® outputs. In this paper I will describe these
global statements and provide examples of their
use.
INTRODUCTION
DATA ACCESS
The first step in any SAS program is to set up
your environment for the session. This includes
telling SAS where to access the data. Next, you
want to format your output so that it looks nice.
You want to set your page size and page
numbering, or even send it to a file in different
formats, such as ASCII text, or the new ODS
system. It is important that the log provides you
with all the information you need to debug your
program. Therefore, there are settings that
control the log output. Finally, there are program
control statements, which cause the program to
execute, stop, or do other file management tasks.
All these statements are external to the DATA
and PROC steps, which are covered at great
length in the manuals and other papers. Global
statements are not executable. They take effect
Before any programming can take place, some
basic options need to be set to define the
locations of where SAS will find the input files and
where it should write any outputs. This is set by
LIBNAME and FILENAME statements.
Accessing data without a libname or filename
statement can be done using quotes around the
complete file address in a data step. However,
this is not efficient programming as the file
locations might change. By using libnames at the
top of your program you create pointers to the
data, which can be easily modified as needed.
The complete libname needs only be typed in
once. Then the individual files in that directory or
library as it is referred to in SAS can be easily
accessed with this alias.
1
NESUG 15
Beginning Tutorials
In order to use libname and filename statements
correctly, one must first have a basic
understanding of how SAS refers to files.
Basically, SAS uses a two level naming
convention as follows: source.filename. The
source is a pointer to the location where the
physical file is stored. This must be referred to by
an alias or libref, which is set with the libname
statement. The libname sets up a SAS data
library, which can be one or more SAS files.
These files are then recognized by the SAS
system and differentiated by their extensions.
(.ssd refers to SAS v.612 datasets, .sd2 refers to
SAS v.8, and .sct refers to format catalogs.)
FILENAME it is compiled. It remains in effect
until the SAS session ends, such as a program
run in batch mode, or until it is reset in an
interactive session. To set a libname statement,
you need the following parts:
LIBNAME libref <engine>”SAS directory”
<options> <engine/host options> ”;
The <engine> option refers to the SAS version
the datasets are stored in. The choices are v612
and v8 for versions 6 and 8 respectively.
Some useful options that can be used are:
ACCESS= READONLY (the default is read/write)
which protects the data from overwriting,
OUTREP = MVS | CMS | WINDOWS | OS2 |
MAC which defines the default for new data sets
that are created in this library. REPEMPTY = NO
prevents an empty dataset from overwriting an
existing dataset with the same name.
Even single level names such as DATA one,
refers to a two level name. In this case, the
dataset ONE is referred to by SAS as
WORK.ONE, as can be seen in the log.
Example 1
5
6
The path to the SAS data directory must be
written specific to the operating environment.
Windows NT and VAX are not case sensitive, so
upper or lower case is allowed interchangeably.
The delimiters are backslashes( \ ). However, in
the UNIX environment, the directory structure
names are case sensitive, and must be referred
to exactly as listed. The delimiters are forward
slashes for UNIX (/).
For example, here is a directory structure:
DATA ONE;
SET MYDATA.DEM;
NOTE: The data set WORK.ONE has 6
observations and 16 variables.
The location of the library WORK is set by the
SAS administrator as defined in the file
SETINIT.SAS. This library contains two types of
temporary files; those that are created by the user
with a one level name, and those used by SAS as
part of normal processing. If a session
terminates normally, these files are deleted by the
system. If there is an abnormal termination,
these files will remain in the WORK library until
overwritten by another file with the same name,
or until manually deleted. To conserve space it
is a good practice to reuse work names such as
one, two, three, during a session.
SASDATA on xyzserver (W:)
|-----0 MYDATA
| ------0 Data
| ------0 Programs
This can be filled in as follows for Windows:
LIBNAME RAWDATA “W:\MYDATA\DATA”
The LIBNAME Statement
Libname statements are just pointers, so there is
no limit to the number of libname statements you
can use in one session. In an interactive
environment, the libname has to be assigned
before the DATA or PROC steps in which they
are referred. SAS compiles from the top down.
As soon as it encounters a LIBNAME or
But for the UNIX environment it is filled in
differently.
LIBNAME RAWDATA “/MYDATA/Data”
There are also shortcuts built into SAS. Below
are three examples to refer to the directory
w:\mydata\etc
2
NESUG 15
Beginning Tutorials
resides within the same root directory. However,
if the program resides in the C: drive and the data
are in W: then the drive letter must be explicitly
defined.
Libname thisdir “w:\mydata\data”;
Libname thisdir “\mydata\data”;
or simply
Libname thisdir ‘ ‘ ; /* refers to current
directory*/
Libname wdrive “w:/project1/mydata” ;
Libname idrive “I:/project1/mydata” ;
The last example is environment-specific. In the
Windows environment, there is a blank between
the two quotes. Quotes can be single or double
(as long as they match), although double-quotes
are necessary if the libname includes a macro or
global variable. Therefore it is a good practice to
always use double-quotes.
In the example above, two different locations are
being indicated. By explicitly indicating the drive,
the program can reside on C: and call to a
remote server.
For those programmers that prefer a GUI
interface, there is also a screen in the interactive
SAS session (both versions 6.12 and 8), where
you can assign and de-assign libnames. On the
toolbar you can click on the file cabinet. This will
open the window as shown below.
One directory can have a mix of SAS engine
versions as long as they are specified in the
libname statement explicitly. If no engine is
specified, SAS assumes the current version of
SAS that is running. However, if you upgrade
SAS and rerun your program it will overwrite that
dataset with the old version as the default unless
there are no datasets of that name residing in that
directory. In other words, it checks the existing
version of that dataset before overwriting.
There are some words you should not use in your
libname statement. These are SASHELP,
SASUSER, and SASWORK. Check your
operating system for others. One easy check is if
you use these libnames, the log will give you a
warning message.
Example 2
6
LIBNAME SASHELP 'C:\MYDATA\';
ERROR: The SAS system library SASHELP
may not be reassigned.
ERROR: Error in the LIBNAME or FILENAME
statement.
Libname thisdir clear; /* now the libname is no
longer referenced */
Note that the libraries LIBRARY, MAPS,
SASHELP, SASUSER and WORK are already
defined. The WORK folder that is highlighted
shows that the assigned folder is c:\program
files\sas612\SASWORK\.. Clicking on New
Library opens the screen to the right where
folders can be assigned interactively to a
libname.
Leaving off the letter designation from the
libname allows multiple users to use the same
program although they may have mapped their
drives to different letters, as long as the program
One other special library is the USER libref. This
library allows you to send the one level name
(normally temporary) files to a User-specified
location, where they are permanently stored.
To disassociate a libref, simply invoke the
libname as follows:
3
NESUG 15
Beginning Tutorials
First a libname has to be created, then USER =
… is defined in the OPTIONS statement.
care of first. The code below was presented in
SUGI27 (see references), and can be used
for other kinds of files as defined in the
Windows ODBC screen:
Example 3
Libname testlib “c:/mydata/test”;
Options user= testlib;
1)
Data region;
Set <more SAS statements>…;
Run;
Another handy feature of using LIBNAMES is
library concatenation. This is the logical
combining of two or more libraries. You can
either concatenate previously defined paths, or
you can specify libname addresses within the
concatenation. This concatenated library has
some read/write rules that must be remembered
in order to prevent spurious results. When there
are datasets within these various addresses with
the same name, the first (left-most) occurrence
of this member will be used for reading and
writing. Consider for example the two libraries
below which are concatenated into ALLDATA:
2)
Go into Windows Start Menu >
Settings > Control Panel> Data
Sources (ODBC) and Add a file
which is named ‘odbcxls’ in the
example below, with the Microsoft
Excel Driver and Excel
spreadsheet attached. (See
Windows help screens for more
information).
Go into Excel spreadsheet and
define a named range. (See Help
in Excel) In the example below the
range is called sheet1.
Example 5
/* Filename to be read in is test.xls */
LIBNAME FILEXLS ODBC DSN = ODBCXLS;
DATA FROM XLS;
SET FILEXLS.SHEET1;
RUN;
Source: SUGI27 paper#25-27
Example 4
LIBNAME DATAONE “C:\mydata\raw”
Contains files labeled demog.sd2, lab.sd2,
random.sd2, CRF.sd2
LIBNAME DATATWO “C:\mydata\final”
Contains files labeled demog.sd2, newlab.sd2,
newCRF.sd2
In this example, whenever demog.sd2 is
referenced (by ALLDATA.DEMOG), only the file
in \raw is being accessed. If it is the intent of the
programmer to use the file in \final first, then the
order of the datasets in the LIBNAME statement
should be reversed. Also, files will only be written
to the first libname mentioned, even if a file of the
same name exists in subsequent LIBNAMES
listed. Additionally, engine options can only be
specified in the original libname.
The FILENAME Statement
The difference between a libname statement and
a filename statement is that filename associates
an alias to the specific file or group of files rather
than to a directory. Assigning a filename alias to
a file is good programming practice, although the
file can also be referred by its full name within the
data step. The advantage of the filename
statement is that many kinds of files can be read
into SAS with the additional information of file
type. The filename statement allows you to
associate device and attributes to the file. It can
be a powerful tool as seen below when we
associate a file to remote storage devices along
with all the information needed to create the
remote connection for data access.
An example of specifying engine options is
accessing an Excel spreadsheet directly
using the ODBC system. There are two
steps external to SAS that need to be taken
Syntax:
FILENAME fileref <device-type> ‘external file’
<host-options> ;
Also:
LIBNAME ALLDATA (DATAONE DATATWO);
4
NESUG 15
Beginning Tutorials
FILENAME fileref clear ;
FILENAME fileref list ;
o
o
A filename can refer to a single file or to an
aggregate file storage location. The aggregate
feature is especially handy in macro programs.
The syntax is slightly different, as we use
parentheses around the fileref in the data step as
shown in the example below.
o
o
o
o
Example 6
Filename sales “c:\mydata\data”;
/* includes the datasets region1.txt region2.txt
region3.txt */
PIPE (not supported by many operating
systems)
PLOTTER (unbuffered graphics output
device)
PRINTER (printer or printer spool file)
TAPE (tape drive)
TEMP (temporary files that can be accessed
only thru its logical name)
TERMINAL (specifies the user’s terminal)
I won’t be discussing all the device types here,
other than to provide some examples. It is
important to note that these devices are available
for use. These are documented in SAS Language
Reference: Dictionary, Version 8 p.823.) One
common use of the devices above would be
TAPE, where the data needs to be retrieved from
a magnetic tape. In this case the filename
statement would read as follows:
data total1;
infile sales(region1);
input widget $ var1 var2 var3 var4;
run;
data total2;
infile sales(region2);
input widget $ var1 var2 var3 var4;
run;
source: p.825 SAS Language Reference:
Dictionary, Version 8.
FILENAME in ‘x:\mydata\text.xls’ TAPE ;
Filenames can have extensions of any kind. SAS
assumes the default is an ASCII file of some sort,
unless defined otherwise in the PROC step. For
instance, to read in an Excel file, use the
following code. (Note that SAS doesn’t determine
what the file type is until the DBMS option is set
to EXCEL in a PROC step.)
Remote connections can be achieved simply by
specifying all the necessary parameters in the
filename statement. This is very handy for
programming systems that require a minimum of
human intervention. It is also essential for
programming web-based applications, which
require connections to be made. Three types of
connections that can be used in the file name
statement are SOCKET, PTP, and URL.
Additional host options can be specified after the
option device-type, check your SAS
documentation for your operating environment for
details.
FILENAME MYDATA
“C:\MYDATA\DOCS\STUDY123.XLS”;
The SOCKET method is a way to access a
remote application such as on a TCP/IP
connection. The syntax for use SOCKET in the
case of a TCP/IP connection is:
PROC ACCESS DBMS=EXCEL;
CREATE WORK._IMEX_.ACCESS;
PATH = MYDATA;
RUN;
FILENAME fileref SOCKET
‘hostname:portno’ <tcpip-options>;
Device types specify a device or acces method
that is not a physical file. These are:
o DISK (this is the default)
o DUMMY (used for testing only, output of file
is discarded)
o GTERM (output device is a graphics device)
The direction of the connection is from the PC to
the remote server. An example is where the data
resides on a UNIX server, but the local PC is
running Windows NT. You need to refer to your
exact hostname:portno and operating system’s
5
NESUG 15
Beginning Tutorials
tcpip options to complete the above statement.
The same applies to PTP and URL.
to 1 by default. But if it were set to 0, then the
original program would not show on the log. This
is sometimes desirable if the program has been
validated already and is very long. The default
settings under SAS log and procedure output can
be visually checked out in version 8. For version
6.12 you need to consult the manuals. Table1
contains a partial table taken from the SAS v8
interactive screens. The column Value shows the
default setting. Referring to Table 1, some
important options for log control are DATE,
FULLSTIMER, STIMER, and ERRORS = n or
NOFMTERR. The written options for DATE are
DATE | NODATE. The options
STIMER|NOSTIMER, and
FULLSTIMER|NOFULLSTIMER give different
levels of running statistics for performance
evaluation, printing them to the log. These
options are essential if you are optimizing
performance of a system. Procedures such as
proc sort or data steps can be written in different
ways to see if the performance indicators show
faster CPU and also real times. Example 7
below shows the various outputs to the log given
by these options.
LOG CONTROL
The log and listing of your SAS session can be
controlled by specifying options in the OPTIONS
statement. An OPTIONS statement can appear
at almost any place in a SAS program including
within a DATA step, except within data lines. The
syntax of this statement is:
OPTIONS <options>;
It gets executed immediately and applies to the
entire interactive or batch SAS session. The
options have default settings set by the SAS
system, and which can be overridden either in the
SETINIT.SAS program or in an individual SAS
program using the OPTIONS statement. After a
program has completed running in batch mode,
the settings default back. However, if you are
running SAS interactively, the settings remain in
place until another OPTIONS statement is
encountered in a program. The OPTIONS
statement can also be changed thru a GUI
interface (version 8 only) in the interactive
session by selecting from the top menu TOOLS >
OPTIONS > SYSTEM.
The statement ERRORS = 1 prevents multiple
errors of the same type to be printed to the log.
NOFMTERR suppresses the error encountered
when a variable has a format attached, which is
not in the format catalog. This allows a program
such as proc freq to run without an error
message, but the values will be unformatted.
The menu divided by categories of Options as
can be seen below:
Example 7
a) 44 options nostimer nofullstimer ;
45
46 proc sort data = cdata;
47 by centre subject; run;
NOTE: There were 16458 observations read from the data set
WORK.CDATA.
NOTE: The data set WORK.CDATA has 16458 observations and
7 variables.
B) 48 options stimer;
49
50 proc sort data = cdata;
51 by centre subject; run;
For log control, there are many useful OPTIONS
that can be specified. In the above list, a 1
indicates true, and 0 indicates false. Source is set
6
/*continued next page*/
NESUG 15
Beginning Tutorials
Thus you can see that you have a lot of control of
what appears in the log, simply by using global
statements. It is especially important when
building macro code to be aware of these
debugging tools available to you.
NOTE: There were 16458 observations read from the data set
WORK.CDATA.
NOTE: The data set WORK.CDATA has 16458 observations and
7 variables.
NOTE: PROCEDURE SORT used:
real time
3.45 seconds
cpu time
0.48 seconds
OUTPUT CONTROL
C) 58 options fullstimer;
59
60 proc sort data = cdata;
61 by centre subject; run;
There are many ways to control the SAS output
without using a PROC step. As mentioned
above, the OPTIONS statement is a key place to
specify output parameters. Appendix 1 lists
several useful options, which should be used in
every program. Two of the first which I advocate
are LINESIZE = (LS= ) and PAGESIZE=
(PS=). These define the number of lines and
rows on your paper. The SAS default basically
fits into the Interactive screen window and doesn’t
fit into any standard paper format. For Portrait, I
recommend LS= 72 (max of 80) and PS = 54
(max of 60), and for landscape LS = 120 (max of
130) and PS = 40. This requires some
experimenting to arrive at a preference for your
system.
NOTE: There were 16458 observations read from the data set
WORK.CDATA.
NOTE: The data set WORK.CDATA has 16458 observations and
7 variables.
NOTE: PROCEDURE SORT used:
real time
3.42 seconds
user cpu time
0.16 seconds
system cpu time 0.39 seconds
Memory
2115k
The macro log options are important debugging
tools. There are several options, which give
varying amounts of printout on the log, or reroute
the macro log output only:
•
•
•
•
MLOGIC will state in the log the
beginning of execution, the value what
the macro variable was replaced with.
MPRINT will print the lines of code
invoked by the macro.
MFILE sends the output created by
MPRINT to an external file.
SYMBOLGEN states each macro
variable name and what it resolves to.
In an interactive session, PAGENO = 1 should be
used at the start of each new program to reset
the pages back to 1. Otherwise in interactive
mode, the pages will be numbered in an odd,
random sort of way, starting at each new output
with the next page from the previous program.
A couple of options that affect the portion
processed by the PROC step are MISSING = and
LABEL | NOLABEL. The Missing option can be
set to any string, such as MISSING = ‘Missing’ or
MISSING = ‘NA’ or Missing = ‘ ’. The label
(nolabel) refers to the Variable labels. If you
specify label then the label will be used rather
than the SAS internal name.
A sample code would be:
Options mfile mprint;
Filename mprint ‘debug.txt’;
There are several global macro statements,
which can also be used for log control. %PUT is
a very useful statement. It is similar to the PUT
statement found in the data step, which places
information on a log, but can be used anywhere.
%PUT can put any character string you want into
the log, and it can also put macro information.
For the macro information there are special
variable names, which include: _ALL_,
_AUTOMATIC_, _GLOBAL_, _LOCAL_,
_USER_, and refer to different types of macro
generated variables.
CENTER | NOCENTER is used to center or left
justify the output. FORMCHAR refers to the table
lines for procedures such as PROC FREQ. The
default formchar works for ASCII files. Another
item that can be specified is FONT. See the
Windows Control Panel for font names. They are
case-sensitive. The font should be fixed-pitch
and not proportional or the text won’t show
correctly in the SAS output. One font that works
is ‘Courier New’. (The log will indicate if the font
7
NESUG 15
Beginning Tutorials
meets the above specifications). The size can
also be defined:
know extensive macro coding. It assigns a value
that can be used in any PROC or DATA step by
using the macro convention &varname. For
instance, in example 6 below the line %LET trial
= ABC123; assigns the string ‘ABC123’ to the
variable &trial. It is then called in the title line1 or
any future titles as needed. The program name is
another handy character string that can be called
into titles or footnotes as shown in example 8
below.
Font = ‘font name’ < size>
FONT = ‘Courier New’ 10
Another output tool is the Output Delivery
System, which will not be covered here, other
than to say that it is available starting in v.8 only.
The ODS system is invoked by commands
starting with ODS. Once invoked, all the
procedures that are run are sent to the ODS
driver. Please refer to the SAS manuals for
details.
Another useful statement is %INCLUDE. This
statement includes another SAS or ASCII file
right into the existing program, allowing the
programmer to write programs in a modular
fashion. It can also be used to call in programs
that contain macros, which are not part of the
standard macro library or user-defined macro
libraries. Programs can be written generically,
and then environment-specific information can be
placed in a separate easy-to edit file that is
project specific. For instance in the example
below, all libname statements and some global
statements are maintained.
Adding title or footnote statements can also
customize output. Title and Footnote syntax is
the same. Titles and Footnotes can be from 1 to
10 lines for SAS. The syntax is:
TITLE<n> “ put title here ”;
FOOTNOTE<n> “put footnote here” ;
They remain in effect until SAS reaches another
TITLE or FOOTNOTE statement specifying a new
title. If the first table has titles1 thru 4 and the
second table has titles 1 thru 3 but title 3 is
different, just writing a new TITLE3 will remove
TITLE4 and also change TITLE3, but TITLE1 and
TITLE2 will remain the same. Single or double
quotes can be used, but it is a good programming
practice to use double-quotes in v.612 since that
is essential for macro variables to be recognized
within a TITLE statement. A new feature of SAS
version 8 and above is that no quotes are needed
at all. Macro variables with no quotes will get
resolved.
Example 8
/* PROGRAM NAME : LIBNAMES.SAS
*/
/* STUDY :
ABC123
*/
/* AUTHOR :
KARIN LAPANN
*/
/* DATE CREATED : 01MAR2002
*/
/* SAS VERSION : SAS 6.12
*/
/* PURPOSE : FOR INCLUSION INTO OTHER PROGRAMS */
/* DESCRIPTION :SET LIBNAME AND OTHER OPTIONS
*/
/*
ONCETHEN CALL INTO OTHER PROGRAMS
*/
/*
also change ddate here
*/
/************************************************/
options nocenter nonumber nodate missing=''
errors=1 ps=40 ls=132;
/*change macro variables below for each data load
************************************************/
%let trial = ABC123;
%let prognam = LIBNAMES.SAS;
%let ddate = 10JUN02;
PROGRAM CONTROL
Programs can be modularized by using global
statements to bring in code from other programs,
and also by using global variables. In this way, a
generic program can be written which can be
implemented across studies or other applications.
Some useful statements are %INCLUDE and
%LET, which are part of the SAS macro
language.
/* This is the map drive letter for UNIX */
/****************************************/
LIBNAME LOAD "/unix1/ABC/123/data/raw";
LIBNAME DLOAD "/unix1/ABC/123/data_clean/edit/test/indata";
LIBNAME LIBRARY "/unix1/ABC/123/data/raw";
LIBNAME OUT "/unix1/ABC/123/data_clean/edit/test/outdata";
TITLE1 “RAW DATA FOR TRIAL &trial LOADED ON &ddate”;
FOOTNOTE1 “Program: &prognam”;
The %LET command creates a global variable
which programmers can uses without having to
8
NESUG 15
Beginning Tutorials
an integral part in program development and are
essential in the communication between human
and machine. The above essay has presented a
broad overview of what is available in the
statements that fall outside the DATA and PROC
steps. Additional OPTIONS are available to
customize your SAS session, which can be
looked up as needed. There are also SAS
manuals for various operating systems, which
provide you with other commands to add to
LIBNAME and FILENAME assignments. By
using the various tips explored above, programs
can be written generically and applied across
many operating systems. The SAS user who
prefers GUI interfaces can use SAS v.8 to set
these options directly in the interactive session.
The batch programmer can develop programs
that will save all of his/her favorite settings.
The code to call in this program into other SAS
programs is:
%INCLUDE libnames.sas;
or %INCLUDE libnames;
In the above examples we are assuming that the
libnames.sas program resides in the same
location as the SAS program. In order to specify
another drive, you just give a more complete
address, such as:
%INCLUDE “c:\mydata\myprog\libnames.sas”;
Note that quotes are not needed around a SAS
program name if it is in the same drive, but if it is
in another location or if the file has a different
extension such as .txt, then it must be explicitly
referenced and have quotes around it. As
always, these can be single or double quotes, but
double quotes are recommended so that any
macro variables within the quotes can be
recognized and resolved.
REFERENCES
SAS Language Reference: Concepts, Version
8, Cary, NC: SAS Institute Inc., 1999
SAS Language Reference: Dictionary, Version
8, Cary, NC: SAS Institute Inc., 1999
SAS Institute Inc., Proceedings of the Twentyseventh Annual SAS® Users Group
International Conference, Cary, NC: SAS
Institute Inc., 1993. Paper #25-27 “Accessing
MICROSOFT EXCEL and MICROSOFT
ACCESS Through the Use of a Simple
Libname Statement ” Kee Lee, Purdue
University, West Lafayette, Indiana
SAS Language Reverence Version 6, First
Edition; Cary, NC: SAS Institute Inc., 1990
Sometimes we only want to run part of a program
during development. In an interactive session,
we can simply highlight the amount of code to run
and hit the run button. When debugging a
program that is written for batch processing, a
handy statement to use is ENDSAS, which
immediately terminates the SAS session at that
line. The logs and listings are still created, as if
the program ended at that point.
ENVIRONMENT CONTROL
The additional feature of the OPTIONS statement
is Environment control, which is beyond the
scope of this paper. These settings are mostly
platform-specific and refer to displaying and
customizing the SAS interactive windows. Suffice
it to say that these additional features exist, and
can be referenced in the SAS manuals in the
interactive session using SAS v.8.
CONTACT INFORMATION
CONCLUSION
SAS® and all other SAS Institute Inc. product or service
names are registered trademarks or trademarks of SAS
Institute Inc. in the USA and other countries. ® indicates
USA registration.
Other brand and product names are registered trademarks
or trademarks of their respective companies.
You can contact the author at:
Karin LaPann
(302) 886-8752
[email protected]
Open code statements that do not fall under
DATA or PROC steps, are often not presented to
new SAS programmers. These statements play
9
NESUG 15
Beginning Tutorials
Table 1
Selected SAS Options for the Global OPTIONS statement
Option name
Value
SAS log and procedure output:
Date
1
Details
1
Linesize
127
Missing
.
Number
Pagesize
1
42
SAS Procedure Output:
Byline
1
Center
1
Formchar
|----|+|----+=|-?|<>*
Formdlim
Label
Pageno
Printinit
Skip
Sysprint
Sysprintfont
SAS Log:
Cpuid
Fullstimer
Stimer
Source
Msgcase
Macro> SAS Macro:
Macro
Mautosource
Merror
Mfile
Mlogic
Mprint
Mrecall
Mstored
Samstore
Serror
Symbolgen
1
1
0
0
\\Uscompany\cp1
Description
Print date on top of page
Display details in directory lists
Line size for SAS output
Character size for missing numeric
value
Print page number
Number of lines per page
Print by-line for each by-group
Center SAS procedure output
Formatting characters for tables, for
print device
Character to delimit page breaks
Allow procedures to use variable labels
New page number for next output page
Initialize SAS print file
Number of lines to skip before title
Set the default printer for SAS
Set the default font for printing
1
0
1
1
0
Print CPU information on log
Writes system performance statistics
Record system performance statistics
Write source statements to log
Use upper case for all messages
1
1
1
0
0
0
0
0
Allow use of macro facility
Allow macro autocall
Treat undefined macros as error
Write MPRINT output to an external file
Trace macro execution
Display macro-generated statements
Search autocall libraries each time
Use stored compiled macros
Libref for compiled stored macro
catalog
Treat undefined macros as error
Write symbolic replacement text to log
1
0
10