If the SAS view exists in a SAS library and if you use the same member name to create a
new view definition, then the old SAS view is overwritten.
Beginning with SAS 8, DATA step views retain source statements. You can retrieve
these statements using the DESCRIBE statement. The following example uses the
DESCRIBE statement in a DATA step view in order to write a copy of the source code
to the SAS log:
For more information about how to create SAS views and use the DESCRIBE statement,
see the DATA statement in SAS Statements: Reference.
What Can You Do with a DATA Step View?
Using a DATA step view, you can do the following:
• directly process any file that can be read with an INPUT statement
• read other SAS data sets
• generate data without using any external data sources and without creating an
intermediate SAS data file
Because DATA step views are generated by the DATA step, they can manipulate and
manage input data from a variety of sources including data from external files and data
from existing SAS data sets. The scope of what you can do with a DATA step view,
therefore, is much broader than that of other types of SAS views.
Differences between DATA Step Views and Stored Compiled DATA
DATA step views and stored compiled DATA step programs differ in the following
• a DATA step view is implicitly executed when it is referenced as an input data set by
another DATA or PROC step. Its main purpose is to provide data, one record at a
time, to the invoking procedure or DATA step.
• a stored compiled DATA step program is explicitly executed when it is specified by
the PGM= option in a DATA statement. Its purpose is usually a more specific task,
such as creating SAS data files, or originating a report.
For more information about stored compiled DATA step programs, see Chapter 28,
“Stored Compiled DATA Step Programs,” on page 679.
Restrictions and Requirements
Global statements do not apply to a DATA step view. Global statements such as the
FILENAME, FOOTNOTE, LIBNAME, OPTIONS, and TITLE statements, even if
included in the DATA step that created the SAS view, have no effect on the SAS view. If
you do include global statements in your source program statements, SAS stores the
DATA step view but not the global statements. When the view is referenced, actual
execution can differ from the intended execution.
When a view is created, the labels for the variable that it returns are also created. If a
DATA step view reads a data set that contains variable labels and a label is changed after
672 Chapter 27 • SAS Views