Chapter Contents |
Previous |
Next |
The SQL Procedure |
See also: | What Are Views? |
Featured in: | Creating a View from a Query's Result |
CREATE VIEW
proc-sql-view AS
query-expression
|
where each libname-clause is one of the following:
LIBNAME libref <engine> ' SAS-data-library' <option(s)> <engine-host-option(s)> |
LIBNAME libref SAS/ACCESS-engine-name <SAS/ACCESS-engine-connection-option(s)> <SAS/ACCESS-engine-LIBNAME-option(s)> |
Arguments |
Sorting Data Retrieved by Views |
Note: If you specify the NUMBER option in the PROC SQL statement when
you create your view, the ROW column appears in the output. However, you cannot
order by the ROW column in subsequent queries. See the description of the NUMBER option .
Librefs and Stored Views |
create view proclib.view1 as select * from invoice where invqty>10;
In this view, VIEW1 and INVOICE are stored permanently in the SAS data library referenced by PROCLIB. Specifying a libref for INVOICE is optional.
Updating Views |
Embedded LIBNAME Statements |
The USING clause must be the last clause in the SELECT statement. Multiple LIBNAME statements can be specified, separated by commas. In the following example, a connection is made and the libref ACCREC is assigned to an ORACLE database.
create view proclib.view1 as select * from accrec.invoices as invoices using libname accrec oracle user=username pass=password path='dbms-path';For more information on the SAS/ACCESS LIBNAME statement, see the SAS/ACCESS documentation for your DBMS.
You can also embed a SAS LIBNAME statement in a view with the USING clause. This enables you to store SAS libref information in the view. Just as in the embedded SAS/ACCESS LIBNAME statement, the scope of the libref is local to the view, and it will not conflict with an identically named libref in the SAS session.
create view work.tableview as select * from proclib.invoices using libname proclib 'sas-data-library';
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.