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.
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
Name: up to eight alphanumeric characters. The library reference (libref) that you want to assign. Use the libref to point SAS to a SAS library or an external data source.
Engine: select the engine that you want to use. The default engine enables SAS to choose which engine to use based on the existing data sets in a library. If no data sets exists in the same location as your new library, the Base SAS engine is assigned.
Enable at startup: select to assign the specified libref to automatically when you open a SAS session.
Path: specifies the path of the libref.
Library Information: represents the SAS/ACCESS connection options and vary according to the SAS/ACCESS engine that you specify. Enter the appropriate information for your PC file format.
OK: click this button to assign the libref, or click Cancel to exit the window without assigning a libref.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.