Previous Page | Next Page

LIBNAME Statement: PC Files on Microsoft Windows

LIBNAME Statement: PC Files on Microsoft Windows

The SAS/ACCESS LIBNAME statement extends the SAS global LIBNAME statement to support assigning a libref to Microsoft Excel files and Microsoft Access files. This enables you to reference spreadsheets and databases directly in a DATA step or SAS procedure. You can also read from and write to a Microsoft Access object or Microsoft Excel object.

See: LIBNAME Statement Syntax


Sorting PC Files Data

When you use the LIBNAME statement to associate a libref with PC files data, you might observe some behavior that differs from that of normal SAS librefs. Because these librefs refer to database and workbook objects, such as tables, they are stored in a format that differs from the format of normal SAS data sets. This is helpful to remember when you access and work with PC files data.

For example, you can sort the observations in a normal SAS data set and store the output to another data set. However, in a Microsoft Access database, sorting data has no effect on how it is stored. Because your data might not be sorted in the external file, you must sort the data at the time of query. When you sort PC files data, the results might vary. Depending on whether the external spreadsheet or database places data has NULL values. If the sort encounters NULL values, are they listed at the beginning or end of the result set. NULL values are translated in SAS to missing values.


Using SAS Functions with PC Files Data

Librefs that refer to PC files with SAS functions might return a different value than the value returned when you use the functions with normal SAS data sets. The PATHNAME function might return a Microsoft Excel filename assigned for the libref. For a normal SAS libref, it returns the pathname for the assigned libref.

Other function options can also vary. The LIBNAME function can accept an optional SAS data-library argument. When you use the LIBNAME function to assign or deassign a libref that refers to PC files data, you omit this argument. For full details about how to use SAS functions, see the SAS Language Reference: Dictionary.


Assigning a Libref Interactively

An easy way to associate a libref with PC files data is to use the New Library user interface. To access: Issue the DMLIBASSIGN command from the SAS session command line. You can also access the New Library window by right-clicking the libraries icon in the Explorer window and selecting New.

New Library

[New Library Dialog]

Previous Page | Next Page | Top of Page