Sample 26053: Convert .sav files into SAS data sets using PROC IMPORT
The first example uses PROC IMPORT to import an SPSS system file (.sav). The second example uses PROC EXPORT to load the SPSS file from a SAS data set. These capabilities are in SAS 9.1.3 SP3 and require a license to SAS/ACCESS to PC File Formats.
To determine which products are licensed at your site, you can look in your SAS Log after submitting the following statements:
proc setinit noalias;
run;
Full syntax for the IMPORT and EXPORT procedures can be found in the SAS Online Documentation under SAS/ACCESS Interface to PC Files.
Click here for documentation
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The PROC IMPORT statement is used to read the SPSS system file with value labels and convert it to a SAS data set with formats. PROC EXPORT loads the SPSS file and converts any user-defined numeric formats to SPSS value labels. Examples follow.
/* EXAMPLE PROC IMPORT */
PROC IMPORT
DATAFILE='c:\filename.sav'
OUT=work.newfilename
DBMS=SAV REPLACE;
RUN;
/* EXAMPLE PROC EXPORT */
PROC EXPORT DATA=sashelp.class
OUTFILE='c:\test'
DBMS=SAV REPLACE;
RUN;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Below, log snippets show expected SAS notes for respective procedures.
You must have a valid SPSS .sav file to run the first example. Look for the formats in the WORK
library. You must save them to a permanent location in order to use these formats in another
SAS session.
6 PROC IMPORT
7 DATAFILE='C:\filename.sav'
8 OUT=work.newfilename
9 DBMS=SAV REPLACE;
NOTE: WORK.NEWFILENAME was successfully created.
If we have formats assigned to the numeric variables, the file 'test.sav'
will contain value labels.
12 PROC EXPORT DATA=sashelp.class
13 OUTFILE='c:\test'
14 DBMS=SAV REPLACE;
NOTE: "c:\test.sav" was successfully created.
Convert a SPSS system file with value labels to a SAS data set with formats. Similarly, PROC EXPORT is used to write a SPSS file from a SAS data set.
Date Modified: | 2006-11-14 03:02:55 |
Date Created: | 2006-05-05 12:41:43 |
Operating System and Release Information
SAS System | Base SAS | Tru64 UNIX | 9.1 TS1M3 | n/a |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 | n/a |
64-bit Enabled AIX | 9.1 TS1M3 | n/a |
64-bit Enabled HP-UX | 9.1 TS1M3 | n/a |
64-bit Enabled Solaris | 9.1 TS1M3 | n/a |
ABI+ for Intel Architecture | 9.1 TS1M3 | n/a |
AIX | 9.1 TS1M3 | n/a |
HP-UX | 9.1 TS1M3 | n/a |
HP-UX IPF | 9.1 TS1M3 | n/a |
Solaris | 9.1 TS1M3 | n/a |
Linux | 9.1 TS1M3 | n/a |
SAS System | SAS/ACCESS Interface to PC Files | Tru64 UNIX | 9.1 TS1M3 | n/a |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 | n/a |
64-bit Enabled AIX | 9.1 TS1M3 | n/a |
64-bit Enabled HP-UX | 9.1 TS1M3 | n/a |
64-bit Enabled Solaris | 9.1 TS1M3 | n/a |
AIX | 9.1 TS1M3 | n/a |
ABI+ for Intel Architecture | 9.1 TS1M3 | n/a |
HP-UX | 9.1 TS1M3 | n/a |
HP-UX IPF | 9.1 TS1M3 | n/a |
Solaris | 9.1 TS1M3 | n/a |
Linux | 9.1 TS1M3 | n/a |