savespss will export data from Stata's memory into an SPSS system (aka binary file) datafile (*.sav).
If instead you want to import SPSS data to Stata, then you need the -usespss- program
savespss facilitates exchange of data between Stata and SPSS. SPSS does not support direct import of datasets in recent Stata formats. Reportedly formats up to Stata 9 are supported by SPSS's import facility. SPSS of versions prior to 14.0 could not import Stata's datasets at all.
This program solves this by allowing Stata users and programmers to export their data directly in SPSS system file format.
The description of assumptions and limitations is organized into the following sections:
Savespss is part of Statistical Software Components (SSC). Individual files are available from this RePEc page. Most users don't need to download individual files and can install with a single command.
To install -savespss- type in Stata:
findit savespssthen follow the link to install the program.
Note: check with SSC regularly to receive further updates!
The main syntax is trivial:
savespsswill show information about the program and ask for filename to export the current data from memory.
savespss "datafile.sav"will export the current data to the specified file. Specify full path if necessary.
savespss "datafile.sav", extmiss("97 98 99")
will export the current data to the specified file, recoding the extended missing values .a, .b, and .c to 97, 98, and 99 respectively for all numeric variables. If option extmiss is not specified, the 'convenient' values will be detected automatically, based on the user data. This takes a bit of time.
In the current version 1.73 the extended missing values can not be suppressed as in the earlier version alltogether by specifying an option extmiss("off"). This option is also not available in the dialog. This option is likely to return in a future version.
To convert a datafile the following sequence can be used:
use "C:\DATA\mydata.dta" savespss "C:\DATA\mydata.sav"
If desired, an option replace can be added to allow overwriting existing file.
For non-ASCII content, option codepage can be used:
savespss "C:\Data\mydata.sav", codepage(1254)
In Stata 13 and newer a strlmax() option may be added to limit the length of strings. This option may be necessary to prevent the output file growing uncontrollably or when it is known the long content will not be required.
Options if and in were frequently requested. I am still investigating, but for now a second, extended version of the dilog exists, which provides these options:
Note that SPSS software blocks data files that it opens for write access by other programs. You will get an error if you attempt to write (export) data to the file currently open in SPSS on your system. This is normal by-design operation (of SPSS) and is not a bug of either side.
The poll is now closed.
The data collected with the poll provided evidence that the majority of the users working with SPSS files (50%) are using the most recent version of SPSS, with 11% using the pre-last version. 25% of the users are somewhere between v15.0 and 19.0. No user reported using SPSS prior to v14.0.
Author and support
In case you are experiencing a problem exporting a dataset, and you think the error is mine, kindly let me know.
savespss was written by Sergiy Radyakin. To contact the author send email to sradyakin/at/worldbank.org.
Or write your questions to Statalist with tag savespss (preferred)