Chapter Contents

Previous

Next
LIBNAME

LIBNAME



Assigns or deassigns a libref for a SAS data library

Category: SAS Table


Syntax
Details
Examples
Example 1: Assigning a Libref
Example 2: Deassigning a Libref
Example 3: Using a List to Assign a Libref to Multiple SAS Data Libraries
See Also

Syntax

sysrc=LIBNAME(libref<,SAS-data-library<,engine <,options>>>);

sysrc
contains the return code for the operation:
0 The operation was successful.
>0 The operation was not successful.
<0 The operation was completed, but a warning or a note was generated.

Type: Numeric

libref
is the libref to assign.

Type: Character

SAS-data-library
is the physical name of the SAS data library to be associated with the libref. This name can be up to 32K characters long. Specify this name as required by the host operating system.

Type: Character

engine
is the engine to use for accessing the SAS files in the data library. If you are specifying a SAS/SHARE server, the engine should be REMOTE.

Type: Character

options
are options that are used by the specified engine. For information about engines and options, see the SAS documentation for your operating environment.

Type: Character


Details

The LIBNAME function follows the rules for the LIBNAME statement in base SAS software.

Operating Environment Information:   Some operating systems allow a SAS-data-library value of ' ' (with a space) and some allow '.' to assign a libref to the current directory. The behavior of LIBNAME when a single space or a period is specified for SAS-data-library is host dependent. Under some operating systems, librefs can be assigned using system commands outside the SAS session.  [cautionend]


Examples

Example 1: Assigning a Libref

Assign the libref NEW to the SAS data library TEST.DATA. If an error or warning occurs, display the message on the message line.

if (libname('new','test.data'))then
   _msg_=sysmsg();

Example 2: Deassigning a Libref

Deassign the libref NEW. If an error or warning occurs, display the message on the message line.

if (libname('new')) then
   _msg_=sysmsg();

Example 3: Using a List to Assign a Libref to Multiple SAS Data Libraries

Assign the libref DEF to several PC files whose names are stored in an SCL list:

lid=makelist();
rc=insertc(lid,"(",-1);
rc=insertc(lid,"'M:\SAS\MAPS'",-1);
rc=insertc(lid,"'C:\CATALOGS\sasuser'",-1);
rc=insertc(lid,")",-1);
rc=libname('DEF',' ','','',lid);

Assign the libref DEF to several UNIX files whose names are stored in an SCL list:

v1="(/mylib/store/data/facilities'";
v2="'/mylib/store/data/hresorces'";
v3="'/mylib/store/data/supplies')";
lid = makelist ();
rc =insertc(lid,v1,-1);
rc =insertc(lid,v2,-1);
rc =insertc(lid,v3,-1);
RC =LIBNAME('DEF',' ',",",lid);

See Also

LIBREF


Chapter Contents

Previous

Next

Top of Page

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