Accessing BMDP, OSIRIS, or SPSS Files in UNIX Environments


Introduction to the BMDP, OSIRIS, and SPSS Files

SAS 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 a BMDP or OSIRIS system file or a SPSS export 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 Procedure" on page 272 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. [1]

Note  

This engine is available for AIX, HP-UX, and Solaris.

Syntax for Accessing BMDP Save Files

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.

Example: BMDP Engine

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. SAS provides the OSIRIS interface library engine to support the many users of the ICPSR data and to be compatible with PROC CONVERT.

With the OSIRIS engine, you can 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.

Notes on the OSIRIS Data Dictionary Files

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 SAS 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.

Syntax for Accessing an OSIRIS File

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 quotation marks. 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.

Example: OSIRIS Engine

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

With the SPSS interface library engine, you can read only SPSS export files. This engine does not read SPSS-X native files.

Syntax for Accessing an SPSS Export File

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 must be created by the SPSS EXPORT command and can originate from any operating environment. Export files must be transported to and from your operating environment in ASCII 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. A common extension for export files is .por, but this extension is not required.

Example: SPSS Engine

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

 libname mylib spss '/users/myid/mydir/myspssx.por';   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.por 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.por';   libname mylib2 spss;   proc print data=mylib2._first_;   run; 

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




SAS 9.1 Companion for UNIX Environments
SAS 9.1 Companion For Unix Enivronments
ISBN: 1590472101
EAN: 2147483647
Year: 2004
Pages: 185
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net