Chapter Contents

Previous

Next
SAS Companion for UNIX Environments

Accessing BMDP, OSIRIS, or SPSS Data Files

Version 7 of the SAS System includes three interface library engines, BMDP, OSIRIS and SPSS, that enable you to access external data directly from a SAS program. All these engines are read-only.

Because they are sequential, these engines cannot be used with the POINT= option on the SET statement or with the FSBROWSE, FSEDIT, or FSVIEW procedures. You can use PROC COPY, PROC DATASETS, or a DATA step to copy the system file to a SAS data set and then perform these functions on the SAS data set. Also, some procedures (such as PROC PRINT) give a warning message about the engine being sequential.

With these engines, the physical filename associated with a libref is an actual filename, not a directory. This is an exception to the rules concerning librefs.

You can also use the CONVERT procedure to convert BMDP, OSIRIS and SPSS files to SAS data files. See CONVERT for more information.


The BMDP Engine

The BMDP interface library engine enables you to read BMDP files from the BMDP statistical software package directly from a SAS program. The BMDP engine is a read-only engine. The following discussion assumes you are familiar with the BMDP save file terminology.(footnote 1)

Note:   This engine is available for AIX, HP-UX, and Solaris.  [cautionend]

To read a BMDP save file, issue a LIBNAME statement that explicitly specifies the BMDP engine. In this case, the LIBNAME statement takes this form:

LIBNAME libref BMDP 'filename';

In this form of the LIBNAME statement, libref is a SAS libref and filename is the BMDP physical filename. If the libref appears previously as a fileref, omit filename because the physical filename associated with the fileref is used. This engine can only read save files created under UNIX.

Because there can be multiple save files in a single physical file, you reference the CODE= value as the member name of the data set within the SAS language. For example, if the save file contains CODE=ABC and CODE=DEF and the libref is MYLIB, you reference them as MYLIB.ABC and MYLIB.DEF. All CONTENT types are treated the same, so even if member DEF is CONTENT=CORR, it is treated as CONTENT=DATA.

If you know that you want to access the first save file in the physical file or if there is only one save file, refer to the member name as _FIRST_. This is convenient if you do not happen to know the CODE= value.

For example, assume that the physical file MYBMDP.DAT contains the save file ABC. The following SAS code associates the libref MYLIB with the BMDP physical file and runs the CONTENTS and PRINT procedures on the save file:

libname mylib bmdp 'mybmdp.dat'; 
proc contents data=mylib.abc; 
run;  
proc print data=mylib.abc; 
run;

The following example uses the LIBNAME statement to associate the libref MYLIB2 with the BMDP physical file. Then it prints the data for the first save file in the physical file:

libname mylib2 bmdp 'mybmdp.dat'; 
proc print data=mylib2._first_; 
run;


The OSIRIS Engine

The Inter-University Consortium on Policy and Social Research (ICPSR) uses the OSIRIS file format for distribution of its data files. The SAS System provides the OSIRIS interface library engine to support the many users of the ICPSR data and to be compatible with PROC CONVERT.

The OSIRIS engine allows you to read OSIRIS data and dictionary files directly from a SAS program. The following discussion assumes you are familiar with the OSIRIS file terminology and structure. If you are not, refer to the documentation provided by the ICPSR.

To read an OSIRIS file, issue a LIBNAME statement that explicitly specifies the OSIRIS engine. The syntax of the LIBNAME statement in this case is

LIBNAME libref OSIRIS 'data-filename' DICT='dictionary-filename';

libref
is a SAS libref.

'data-filename'
is the physical filename of the data file. If the libref appears also as a fileref, omit the data filename.

'dictionary-filename'
is the physical filename of the dictionary file. The dictionary filename can also be an environment variable or a fileref, but if it is either of those, do not enclose it in quotes. The DICT= option is required.

OSIRIS data files do not have member names. Therefore, use whatever member name you like.

To use the same dictionary file with different data files, code a separate LIBNAME statement for each one.

Since the OSIRIS software does not run outside the MVS environment, the layout of an OSIRIS data dictionary is consistent across operating environments. However, the OSIRIS engine is designed to accept a data dictionary from any other operating environment on which the SAS System runs. It is important that the dictionary and data files not be converted from EBCDIC to ASCII; the engine expects EBCDIC data.

The dictionary file should consist of fixed-length records of length 80. The data file should contain records large enough to hold the data described in the dictionary.

In the following example, the data file is /users/myid/osr/dat, and the dictionary file is /users/myid/osr/dic. The example associates the libref MYLIB with the OSIRIS files and runs a PROC CONTENTS and PROC PRINT on the data.

libname mylib osiris '/users/myid/osr/dat'
   dict='/users/myid/osr/dic';  
proc contents data=mylib._first_; 
run;  
proc print data=mylib._first_; 
run;


The SPSS Engine

The SPSS interface library engine allows you to read only SPSS export files. This engine does not read Release 9 and SPSS-X native files. The following discussion assumes that you are familiar with the SPSS save file terminology and structure. If you are not, refer to the documentation provided by SPSS.

To read an SPSS export file, issue a LIBNAME statement that explicitly specifies the SPSS engine. The syntax of the LIBNAME statement in this case is

LIBNAME libref SPSS 'filename';
Libref is a SAS libref and filename is the physical filename. If the libref appears also as a fileref, omit filename; the physical filename associated with the fileref is used.

Export files can originate from any operating environment. Export files must be transported to and from your operating environment in text format. If they are transported in binary format, other operating environments will not be able to read them.

Because SPSS-X files do not have internal names, refer to them by any member name you like.

The following example associates the libref MYLIB with the physical file /users/myid/mydir/myspssx.spp in order to run the CONTENTS and PRINT procedures on the save file:

libname mylib spss '/users/myid/mydir/myspssx.spp';
proc contents data=mylib._first_; 
proc print data=mylib._first_; 
run;
In the next example, the FILENAME statement associates the fileref MYLIB2 with the /users/myid/mydir/aspssx.spp SPSS physical file, and the LIBNAME statement associates the libref with the SPSS engine. The PRINT procedure prints the data from the save file.
filename mylib2 '/users/myid/mydir/aspssx.spp'; 
libname mylib2 spss;
proc print data=mylib2._first_; 
run;

FOOTNOTE 1:  See the documentation provided by BMDP Statistical Software Inc. for more information. [arrow]


Chapter Contents

Previous

Next

Top of Page

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