help dta2sav-------------------------------------------------------------------------------

Title

dta2sav- Create SPSS syntax to convert Stata data into SPSS data

Syntax

dta2sav[varlist] [if] [in] [,options]

optiondescription -------------------------------------------------------------------------NODotssupress dots showing progressVerboseshow MISSING VALUES commands of SPSS syntax in listingname(name)specify (path and) name of .dts and .sps filesreplacereplace existing .dts (Stata data) and .sps (SPSS syntax) files

Description

dta2savcreates SPSS syntax and a Stata data file to convert Stata data into SPSS data. Extended missing values (see: missing) which are labeled will be encoded into "numeric" values which will be defined as missing by using SPSS syntax commands created bydta2sav. This allows to preserve labels of missing values as defined in Stata for subsequent use in SPSS.dta2savsaves data in memory into a file in Stata 9/Stata 10 format with the extension .dts. The respective SPSS commands will be saved into an SPSS syntax file with the extension .sps.varlistand [if] [in] can be used to restrict data to be imported by SPSS.The rule to encode the extended missing values into "numeric" values is easier to understand by an example than by an abstract description: Imagine that the maximum valid value is a one digit integer, say 1, and there are two extended missing values .a and .b which are labeled. In this case .a will be encoded into 9, the maximum possible one-digit integer. .b will be encoded into a next smaller integer, in this case 8. If, however, the maximum valid value is 998 and there are three extended missing values .a, .b, and .d which are labeled (e.g. "not known", "not applicable", and "> 998"), there are not enough three-digits integers greater than 998. Therefore, .a will be encoded into 9999, .b into 9998, and .d into 9997 and SPSS syntax will be created that defines the values 9999, 9998, and 9997 as missing (after the task

dta2savis completed, the original data will be restored in memory).In general,

dta2savwill determine the number of digits D of the maximum valid integer and, if possible, will encode the first extended missing value (normally .a) (if it is labeled) into the maximum integer which can be displayed using D digits. Subsequent extended missing values corresponding to the remaining extended missings will be (if labeled) encoded into consecutively descending integers. If D is too small to encode all extended missings that way, the digits D to display the encoded "numeric" missings will be increased by one.If no path and filename is specified by using the option

name(name), the name of the Stata data file in memory will be used for the filenames of the Stata data file with the extension .dts and the SPSS syntax file with the extension .sps. If not specified, the path will be extracted from the path of the Stata data file in memory.

Example

. sysuse auto.. recode rep78 (.=.a), gen(rep78m)// note: no label of .a. recode price (10000/max = .a ">= 10,000"), gen(pricem). label define origin .a "n.k." .b "n.a." .d "ambiguous", modify.. dta2sav, nod v name(`"`c(pwd)'/foo"')// use working directoryDepending on the paths actually used, the result window will show the following listing of SPSS commands saved into the file foo.sps:

SPSS syntax: +--------------------------------------------------------------------------+ | /* ------------------------------------------------------------------ */ | | /* 1978 Automobile Data */ | | /* Filename: 'C:\Program Files (x86)\Stata12\ado\base/a/auto.dta' */ | | /* File changed since 13 Apr 2011 17:45 */ | | /* Cases: 74 (exported 74), variables: 14 (exported 14) */ | | /* Exported from Stata: 18 Jan 2012 19:07:28 */ | | /* ------------------------------------------------------------------ */ | | | | GET STATA FILE='d:\Statist\Stata\Data/foo.dts'. | | FILE LABEL 1978 Automobile Data. | | | | MISSING VALUES foreign (7 THRU 9). | | MISSING VALUES pricem (9999). | | | | SAVE OUTFILE = 'd:\Statist\Stata\Data/foo.sav'. | +--------------------------------------------------------------------------+

AuthorDirk Enzmann Institute of Criminal Sciences, Hamburg email: mailto:dirk.enzmann@uni-hamburg.de