Chapter Contents

Previous

Next
SAS Companion for the Microsoft Windows Environment

Reading BMDP, OSIRIS and SPSS Files

Version 8 of the SAS System provides three interface library engines that enable you to access external data files directly from a SAS program: the BMDP, OSIRIS and SPSS engines. These engines are all read-only. Because they are sequential engines (that is, they do not support random access of data), these engines cannot be used with the POINT= option in the SET statement or with the FSBROWSE, FSEDIT, or FSVIEW procedures. You can use PROC COPY 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, because they are sequential engines, some procedures (such as the PRINT procedure) give a warning message that the engine is sequential. With these engines, the physical filename associated with a libref is an actual filename, not a folder. 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. For more information, see CONVERT.


BMDP Engine

The BMDP interface library engine enables you to read BMDP DOS 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.

To read a BMDP save file, you must issue a LIBNAME statement that explicitly specifies you want to use the BMDP engine. In this case, the LIBNAME statement take the following 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, you can omit filename because the physical filename associated with the fileref is used. This engine can only read BMDP save files created under DOS.

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, you can refer to the member name as _FIRST_. This is convenient if you don't know the CODE= value.

BMDP Engine Examples

In the following example, the physical file MYBMDP.DAT contains the save file ABC. This example associates the libref MYLIB with the BMDP physical file, then 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 dat=mylib2._first_;
   run;


OSIRIS Engine

Because 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 data from ICPSR and to be compatible with PROC CONVERT, which is described in CONVERT.

The read-only OSIRIS engine enables you to read OSIRIS data and dictionary files directly from a SAS program. These files must be stored in EBCDIC format. This means you must have downloaded the OSIRIS files from your host computer in binary format. The following discussion assumes you are familiar with the OSIRIS file terminology. (footnote 1)

To read an OSIRIS file, you must issue a LIBNAME statement that explicitly specifies you want to use the OSIRIS engine. In this case, the LIBNAME statement takes the following form:

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

In this form of the LIBNAME statement, libref is a SAS libref, data-filename is the physical filename of the OSIRIS data file, and dictionary-filename is the physical filename of the OSIRIS dictionary file. The dictionary-filename argument can also be an environment variable name or a fileref. (Do not put it in quotes if it is an environment variable name or fileref.) The DICT= option must appear because the engine requires both files.

OSIRIS data files do not have member names. Therefore, you can use whatever member name you like. You can use the same OSIRIS dictionary file with different OSIRIS data files. Simply write a separate LIBNAME statement for each one.

The layout of an OSIRIS data dictionary is consistent across operating systems. This is because the OSIRIS software does not run outside of the OS/390 environment, but the engine is designed to accept an OS/390 data dictionary on any other operating system under which the SAS System runs. It is important that the OSIRIS dictionary and data files not be converted from EBCDIC to ASCII; the engine expects EBCDIC data. There is no specific file layout for the OSIRIS data file. The file layout is dictated by the contents of the OSIRIS dictionary file.

OSIRIS Engine Example

In the following example, the data file is MYOSIRIS.DAT, and the dictionary file is MYOSIRIS.DIC. The example associates the libref MYLIB with the OSIRIS files and then runs PROC CONTENTS and PROC PRINT on the data:

libname mylib osiris 'myosiris.dat' 
        dict='myosiris.dic';
proc contents data=mylib._first_;
run;
proc print data=mylib._first_;
run;


SPSS Engine

The SPSS interface library engine enables you to read SPSS/PC files directly from a SAS program. This is a read-only engine. The following discussion assumes you are familiar with the SPSS save file terminology. (footnote 2)

To read an SPSS save file, you must issue a LIBNAME statement that explicitly specifies you want to use the SPSS engine. In this case, the LIBNAME statement takes the following form:

LIBNAME libref SPSS <'filename'>;

In this form of the LIBNAME statement, the libref argument is a SAS libref, and filename is the SPSS physical filename. If the libref appears also as a fileref, you can omit filename because the physical filename associated with the fileref is used. The SPSS/PC native file format, as well as the export file format, is supported. The engine determines which format is used and reads the save file accordingly. Native files must be created under PC DOS. Export files can originate from any operating system.

Because SPSS/PC files do not have internal names, you can refer to them by any member name you like. (The example in this discussion uses _FIRST_ .)

SPSS Engine Example

The following example associates the libref MYLIB with the physical file MYSPSS.DAT in order to run PROC CONTENTS and PROC PRINT on the save file:

libname mylib spss 'myspss.dat';
proc contents data=mylib._first_;
run;
proc print data=mylib._first_;
run;

FOOTNOTE 1:  See documentation provided by the Institute for Social Research for more information. [arrow]

FOOTNOTE 2:  See documentation provided by SPSS Inc. for more information. [arrow]


Chapter Contents

Previous

Next

Top of Page

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