Chapter Contents

Previous

Next
SAS/SHARE User's Guide

Accessing Libraries through a Server

To access a SAS data library or an external DBMS through a SAS/SHARE server, you must use the REMOTE engine to define a libref for the library. Use a LIBNAME statement that specifies the libref and that identifies the library or the DBMS and the SAS/SHARE server that you will use to access it. Here is a typical LIBNAME statement:

libname invoice '/dept/acct/data/invoice' server=share1;

In this example, the engine name REMOTE, which is normally specified between the libref and the pathname, is omitted because it is implied by the SERVER= option.

If the library is pre-defined to the server by a server administrator, you can omit the pathname and use only the libref, which is defined for the library in the server SAS session, to identify the library:

libname invdata server=share1;

In this case, the REMOTE engine and the server assume that the libref that you define for your SAS session is also the libref that is defined by the server administrator in the server session. Omitting the path name protects your application if the path name for the library has changed.

If the library is pre-defined to the server but you want to define a different libref from the one that is defined in the server session, use the SLIBREF= option to specify the server libref:

libname invoice server=share1 slibref=invdata;

If the server runs with the option NOALLOC in effect, all libraries that are accessed through that server must be pre-defined by the server administrator.

For details about the LIBNAME statement syntax, see The LIBNAME Statement.


Using Macros to Generate a LIBNAME Statement

Hard coding the server name in a LIBNAME statement can be a problem if the server administrator shifts one server's traffic to another server, thereby invalidating the server name.

You can avoid this problem by using a SAS macro to generate the required LIBNAME statement. If you use a macro in your end-user application, you can change the name of the server in one place, even though multiple applications access data through that server. This makes it easier to maintain your SAS programs.

SAS/SHARE software provides macros for generating LIBNAME statements. To associate a server name with a SAS data library, register the library in a table that the server administrator maintains. Instead of specifying a LIBNAME statement to access the library, use the LIBDEF macro. When you invoke the LIBDEF macro, it searches the table of registered data libraries for the specified library. When the LIBDEF macro finds the library, it uses the associated server name and the specified libref to construct the LIBNAME statement. Before the first invocation of the LIBDEF macro in a SAS execution, you must invoke the SHRMACS macro with the keyword USER.

   %shrmacs(user);

The SHRMACS macro generates and compiles other SAS/SHARE macros and builds the SAS server-alias and library-alias tables in which server libraries are registered.

To invoke the LIBDEF macro, specify the libref and the optional server library, as shown in this example:

   %libdef(datalib<,SAS-data-library>);

For more information about using the LIBDEF macro, see Generating a LIBNAME Statement (LIBDEF). For complete details about macro syntax, see SAS/SHARE Macros. Contact your server administrator for information about how the macros and tables are implemented and how they are used at your site.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.