While SAS
data files and SAS data views can, for the
most part, be used interchangeably in a SAS DATA step, here are a few differences
to keep in mind:
- The main difference is where the values
are stored. A SAS data file is a type of SAS data set that contains
both descriptor information about the data and the data values themselves.
SAS data views contain only descriptor information that points to data values
that are stored elsewhere.
- A data file is a static picture; a data
view is a dynamic picture. When you reference a data file in a later
PROC step, you see the data values as they were when the data file was created
or last updated. When you reference a data view in a PROC step, the view executes
and provides you with an image of the data values as they currently exist,
not as they existed when the view was defined.
- SAS data files can be created on tape, or
on any other storage medium.
SAS data views cannot be created or stored on tape,
or generated from data files stored on tape. Because of their dynamic nature,
SAS data views must derive their information from data files on random-access
storage devices, such as disk drives. SAS data views cannot derive their information
from files stored on sequentially accessed storage devices, such as tape drives.
- SAS data views are read-only. You
cannot write to a data view.
- SAS data files can have integrity constraints. When you update a SAS data file, you can ensure that the data conforms
to certain standards by using integrity constraints. With data views, this
may only be done indirectly, by assigning integrity constraints to the data
files that the data views reference.
- SAS data files can be indexed. Indexing
may allow SAS to find data in a SAS data file more quickly. SAS data views
cannot be indexed.
- SAS data files can be encrypted.
Encryption provides an extra layer of security to physical files. SAS data
views cannot be encrypted.
- SAS data files can be compressed.
Compression makes it possible to store physical files in less space. SAS data
views cannot be compressed.
The following table illustrates native and interface SAS
data files and their relationship to SAS data views.
Types of SAS Data Sets
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.