O'Reilly logo

SAS 9.4 Language Reference, 6th Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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;
run; 8
proc print data=myv9lib.problems;
format date datetime18.;
run; 9
1
Reference a library called MyV9Lib. Tell SAS where a file that associated with the
fileref Student is stored.
2
Create a data file called Problems and a SAS view called Class and specify the
column names for both data sets.
3
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.
4
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.
5
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.
6
Place all other observations, which have none of the specified errors, in the SAS
view called MyV9Lib.Class.
7
The FILENAME statement assigns the fileref Student to an external file. The
LIBNAME statement assigns the libref MyV9Lib to a SAS library.
8
The first PROC PRINT calls the SAS view MyV9Lib.Class. The SAS view extracts
data on the fly from the file referenced as Student.
9
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 675

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required