13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

90 LIBNAME Statement Syntax <strong>for</strong> <strong>Relational</strong> <strong>Databases</strong> 4 Chapter 10reference section <strong>for</strong> your <strong>SAS</strong>/<strong>ACCESS</strong> interface . For more in<strong>for</strong>mation aboutLIBNAME options, see “LIBNAME Options <strong>for</strong> <strong>Relational</strong> <strong>Databases</strong>” on page 92.CLEARdisassociates one or more currently assigned librefs.Specify libref to disassociate a single libref. Specify _ALL_ to disassociate allcurrently assigned librefs._ALL_specifies that the CLEAR or LIST argument applies to all currently assigned librefs.LISTwrites the attributes of one or more <strong>SAS</strong>/<strong>ACCESS</strong> libraries or <strong>SAS</strong> libraries to the<strong>SAS</strong> log.Specify libref to list the attributes of a single <strong>SAS</strong>/<strong>ACCESS</strong> library or <strong>SAS</strong> library.Specify _ALL_ to list the attributes of all libraries that have librefs in your currentsession.Detailsu Using Data from a DBMS You can use a LIBNAME statement to read from andwrite to a DBMS table or view as if it were a <strong>SAS</strong> data set.For example, in MYDBLIB.EMPLOYEES_Q2, MYDBLIB is a <strong>SAS</strong> libref that pointsto a particular group of DBMS objects, and EMPLOYEES_Q2 is a DBMS table name.When you specify MYDBLIB.EMPLOYEES_Q2 in a DATA step or procedure, youdynamically access the DBMS table. <strong>SAS</strong> supports reading, updating, creating, anddeleting DBMS tables dynamically.v Disassociating a Libref from a <strong>SAS</strong> Library To disassociate or clear a libref from aDBMS, use a LIBNAME statement. Specify the libref (<strong>for</strong> example, MYDBLIB) and theCLEAR option as shown here:libname mydblib CLEAR;You can clear a single specified libref or all current librefs.The database engine disconnects from the database and closes any free threads orresources that are associated with that libref’s connection.w Writing <strong>SAS</strong> Library Attributes to the <strong>SAS</strong> Log Use a LIBNAME statement to writethe attributes of one or more <strong>SAS</strong>/<strong>ACCESS</strong> libraries or <strong>SAS</strong> libraries to the <strong>SAS</strong> log.Specify libref to list the attributes of a single <strong>SAS</strong>/<strong>ACCESS</strong> library or <strong>SAS</strong> library, asfollows:libname mydblib LIST;Specify _ALL_ to list the attributes of all libraries that have librefs in your currentsession.SQL Views with Embedded LIBNAME StatementsWith <strong>SAS</strong> software, you can embed LIBNAME statements in the definition of an SQLview. This means that you can store a LIBNAME statement in an SQL view thatcontains all in<strong>for</strong>mation that is required to connect to a DBMS. Whenever the SQL viewis read, PROC SQL uses the embedded LIBNAME statement to assign a libref. Afterthe view has been processed, PROC SQL de-assigns the libref.In this example, an SQL view of the Oracle table DEPT is created. Whenever youuse this view in a <strong>SAS</strong> program, the ORALIB library is assigned. The library uses the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!