mids object to SPSSmids object into a format recognized by
SPSS, and writes the data and the SPSS syntax files.mids2spss(imp, filedat = "midsdata.txt", filesps = "readmids.sps",
path = getwd(), sep = "\t", dec = ".", silent = FALSE)imp argument is an object of class
mids, typically produced by the mice()
function.path is appended to
filedat and filesps. By default, files are
written to the current R working directory. If
path=NUNULL.mids object to SPSS. It uses a modified version of
writeForeignSPSS() from the foreign package.
The modified version allows for a choice of the field and
decimal separators, and makes some improvements to the
formatting, so that the generated syntax file is amenable
to the INCLUDE statement in SPSS.Below are some things to pay attention to.
The SPSS syntax file has the proper file names and
separators set, so in principle it should run and read the
data without alteration. SPSS is more strict than
R with respect to the paths. Always use the full
path, otherwise SPSS may not be able to find the
data file.
Factors in R translate into categorical variables in
SPSS. The internal coding of factor levels used in
R is exported. This is generally acceptable for
SPSS. However, when the data are to be combined with
existing SPSS data, watch out for any changes in the
factor levels codes. The read.spss() in package
foreign for reading .sav uses its own
internal numbering scheme 1,2,3,... for the levels
of a factor. Consequently, changes in factor code can cause
discrepancies in factor level when re-imported to
SPSS. The solution is to manually recode the factor
level in SPSS.
SPSS will recognize the data set as a multiply
imputed data set, and do automatic pooling in procedures
where that is supported. Note however that pooling is an
extra option only available to those who licence the
MISSING VALUES module. Without this licence,
SPSS will still recognize the structure of the data,
but not do any pooling.
mids