SAS Institute. The Power to Know

SAS/ACCESS(R) 9.2 Interface to PC Files: Reference

space
Previous Page | Next Page

File Format-Specific Reference for 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 Examples of Importing and Exporting SPSS SAV Files.


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 truncation results in the same name as another variable, the last character is changed to a single digit (1, 2, 3, and so on) until the variable name becomes unique.

Variable Labels

SPSS supports variable labels. When exporting, if the variable name is not a valid SPSS name and if there is no label, PROC EXPORT writes the variable name to an SPSS file as the label.

Value Labels

SPSS stores value labels within the data file. The values are turned into format library entries as they are read with PROC IMPORT. 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.

PROC EXPORT saves the value labels that are associated with the variables when writing to an SPSS file. It uses the formats that are associated with the variables to retrieve the value entries.

Data Types

SPSS supports numeric and character field types that map directly to SAS numeric and character fields. The following list shows other SPSS data types and how PROC IMPORT 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, PROC EXPORT 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 the following 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.


Examples of Importing and Exporting SPSS SAV Files

  • Export a SAS Data Set to an SPSS SAV File

    The following example code exports the SAS data set, SDF.CUSTOMER, to the SPSS SAV file, customer.sav, on a local system.

    LIBNAME SDF V9 "&sasdir";
    PROC EXPORT DATA=SDF.CUSTOMER
                FILE="&tmpdir.customer.sav"
                DBMS=SPSS REPLACE;
    RUN;
  • Import a SAS Data Set from an SPSS SAV File

    The following example code imports the SAS data set, WORK.CUSTOMER, from the SPSS SAV file, customer.sav, on a local system.

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

space
Previous Page | Next Page | Top of Page