• New records, if error free, that are added to the source data file Student between the
time you run the DATA step in the previous example and the time you execute
PROC PRINT in the following example, appear in the SAS view MyV9Lib.Class.
• On the other hand, if any new records, failing the error tests, were added to Student,
the new records would not show up in the SAS data file MyV9Lib.Problems, until
you run the DATA step again.
A SAS view dynamically updates from its source files each time it is used. A SAS data
file, each time it is used, remains the same, unless new data is written directly to the file.
filename student 'external-file-specification';
libname myv9lib 'SAS–library'; 7
proc print data=myv9lib.class;
proc print data=myv9lib.problems;
format date datetime18.;
Reference a library called MyV9Lib. Tell SAS where a file that associated with the
fileref Student is stored.
Create a data file called Problems and a SAS view called Class and specify the
column names for both data sets.
Select the file that is referenced by the fileref Student and select the data in character
format that resides in the specified positions in the file. Assign column names.
When data in the column Name, Major, or Credits is blank or missing, assign a code
of 01 to the observation where the missing value occurred. Also assign a SAS
datetime code to the error and place the information in a file called Problems.
When the number of credits is greater than zero, but less than ninety, list the
observations as code 02 in the file called Problems and assign a SAS datetime code
to the observation.
Place all other observations, which have none of the specified errors, in the SAS
view called MyV9Lib.Class.
The FILENAME statement assigns the fileref Student to an external file. The
LIBNAME statement assigns the libref MyV9Lib to a SAS library.
The first PROC PRINT calls the SAS view MyV9Lib.Class. The SAS view extracts
data on the fly from the file referenced as Student.
This PROC PRINT prints the contents of the data file MyV9Lib.Problems.
PROC SQL Views
A PROC SQL view is a PROC SQL query expression that is given a name and stored for
later use. When you use a PROC SQL view in a SAS program, the view derives its data
from the data sets (often referred to as tables) or SAS views listed in its FROM clause.
The data that is accessed by the view is a subset or superset of the data in its underlying
data sets or SAS views.
A PROC SQL view can read or write data from:
PROC SQL Views 651
Get SAS 9.4 Language Reference, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.