|File Format-Specific Reference for the IMPORT and EXPORT Procedures|
|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.
|SPSS Data Types|
SPSS supports missing values. SAS missing values are written as SPSS missing values.
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.
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.
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.
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.
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:
|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.
|IMPORT Procedure and the EXPORT Procedure Supported Syntax|
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.
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;
This example imports data from customer.sav, on a local system, to the SAS data set WORK.CUSTOMER.
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;
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;