Previous Page | Next Page

File Format-Specific Reference for the IMPORT and EXPORT Procedures

SPSS SAV Files


SAV File Essentials

All versions of SPSS under Microsoft Windows are supported. SPSS files have a .sav file extension. SPSS files that have short variable names are exported.

See: Example 1: EXPORT a SAS Data Set to an SPSS SAV File


SPSS Data Types

MISSING VALUES

SPSS supports missing values. SAS missing values are written as SPSS missing values.

VARIABLE NAMES

Only the short variable name style is supported. SPSS variable names can be up to eight characters in length. All alphabetic characters must be uppercase. The first character in a variable name can be an uppercase letter (A-Z), a dollar sign ($), or an "at" sign (@). Subsequent characters can be any of these characters, plus numerals (0-9), periods (.), number signs (#), or underscores ( _ ).

SPSS reserves 13 words, which are not allowed to stand alone as variable names: ALL, AND, BY, EQ, GE, GT, LE, LT, NE, NOT, OR, TO, and WITH. If the program encounters any of these as a variable name, it appends an underscore to the variable name to distinguish it from the reserved word. For example, ALL becomes ALL_ .

Invalid characters are converted to underscores unless they are encountered as the first character in a variable name. In that event, the "at" sign (@) is used instead. For example, %ALL becomes @ALL .

When you are exporting to SPSS, SAS variable names that are longer than eight characters are truncated to eight characters. If the new name is truncated and results in an existing name, the last character changes to a single digit (1,2, 3...) until the variable name becomes unique.

VALUE LABELS

SPSS stores value labels within the data file. The values are turned into format library entries as they are read with the IMPORT procedure. The name of the format includes its associated variable name, modified to meet the requirements of format names. The name of the format is also associated with a variable in the data set. You can use the FMTLIB=libref.format-catalog; statement to save the formats catalog in a specified SAS library.

The EXPORT procedure saves the value labels that are associated with the variables when writing to an SPSS file. The procedure uses the formats that are associated with the variables to retrieve the value entries. You can use the FMTLIB=libref.format-catalog statement to tell SAS the location of the format catalog.

VARIABLE LABELS

SPSS supports variable labels. the EXPORT procedure writes the variable name to an SPSS file as the label if the variable name is not a valid SPSS name and no label exists.

DATA TYPES

SPSS supports numeric and character field types that map directly to SAS numeric and character fields. This list shows other SPSS data types and how the IMPORT procedure converts them to SAS formats.

Date, Jdate, Wkday, Qyr, Wkyr: Date, Jdate, Wkday, Qyr, Wkyr

Datetime, Dtime: Converts to a SAS datetime value and SAS datetime format.

Time: Converts to a SAS datetime value and SAS datetime format.

Adate: Converts to a SAS date value in the mmddyy format.

Moyr: Converts to a SAS date value in the mmmyy format.

When writing SAS data to an SPSS file, the EXPORT procedure converts data into SPSS variable types.

When exporting data, character fields have a maximum length of 256.

Numeric fields are 8-byte floating-point numbers, with these format conversions:

COMMA

Converts to SPSS format type comma.

DOLLAR

Converts to SPSS format type dollar.

DATE

Converts to SPSS format type date.

MMDDYY

Converts to SPSS format Adate.

MMMYY

Converts to SPSS format Moyr.

DATETIME

Converts to SPSS format Dtime.

TIME

Converts to SPSS format Time.


Importing and Exporting Data in SPSS Files

PC Files Server (DBMS=PCFS)

This IMPORT|EXPORT method uses the client/server model to access data in Stata files on Microsoft Windows from Linux, UNIX, or Microsoft Windows 64-bit operating environments. This method requires running the PC Files Server on Microsoft Windows.

Note: A filename with a .sav extension is required.

IMPORT Procedure and the EXPORT Procedure Supported Syntax

FMTLIB=libref.format-catalog

When importing an SPSS file, SAS saves value labels to a specified SAS format catalog. When exporting a SAS data set to an SPSS file, SAS writes the specified SAS format catalog to the SPSS file.


Example 1: EXPORT a SAS Data Set to an SPSS SAV File

This example exports the SAS data set SDF.CUSTOMER, to the SPSS file, CUSTOMER.SAV, on a local system.

LIBNAME SDF "&sasdir";
PROC EXPORT DATA=SDF.CUSTOMER
            FILE="&tmpdir.customer.sav"
            DBMS=SPSS REPLACE;
RUN;


Example 2: Import a SAS Data Set from an SPSS SAV File

This example imports data from customer.sav, on a local system, to the SAS data set WORK.CUSTOMER.

PROC IMPORT OUT=WORK.CUSTOMER
            FILE="&tmpdir.customer.sav"
            DBMS=SPSS REPLACE;
RUN;


Example 3: Export a SAS Data Set on UNIX to an SPSS File on Microsoft Windows

This example exports a SAS data set named SDF.CUSTOMER to an SPSS file named CUSTOMER.SAV. Note that SAS is running on the UNIX operating platform. The SPSS file is loaded on Microsoft Windows where PC Files Server is running.

LIBNAME SDF "&sasdir";
PROC EXPORT DATA=SDF.CUSTOMER
            FILE="&tmpdir.customer.sav"
            DBMS=PCFS REPLACE;
   SERVER="&server";
 RUN;


Example 4: IMPORT Data from an SPSS File on Microsoft Windows to a SAS Data Set on UNIX

This example imports data from an SPSS file named CUSTOMER.SAV to a SAS data set named WORK.CUSTOMER. Note that SAS is running on a UNIX platform. The SPSS file is located on Microsoft Windows where PC Files Server is running.

PROC IMPORT OUT= WORK.CUSTOMER
            FILE="&tmpdir.customer.sav"
            DBMS=PCFS REPLACE;
  SERVER="&server";
RUN;

Previous Page | Next Page | Top of Page