mids2spss: Export 'mids' object to SPSS

View source: R/mids2spss.R

mids2spssR Documentation

Export mids object to SPSS

Description

Converts a mids object into a format recognized by SPSS, and writes the data and the SPSS syntax files.

Usage

mids2spss(
  imp,
  filename = "midsdata",
  path = getwd(),
  compress = FALSE,
  silent = FALSE
)

Arguments

imp

The imp argument is an object of class mids, typically produced by the mice() function.

filename

A character string describing the name of the output data file and its extension.

path

A character string containing the path of the output file. The value in path is appended to filedat. By default, files are written to the current R working directory. If path=NULL then no file path appending is done.

compress

A logical flag stating whether the resulting SPSS set should be a compressed .zsav file.

silent

A logical flag stating whether the location of the saved file should be printed.

Details

This function automates most of the work needed to export a mids object to SPSS. It uses haven::write_sav() to facilitate the export to an SPSS .sav or .zsav file.

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.

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 license the MISSING VALUES module. Without this license, SPSS will still recognize the structure of the data, but it will not pool the multiply imputed estimates into a single inference.

Value

The return value is NULL.

Author(s)

Gerko Vink, dec 2020.

See Also

mids


mice documentation built on June 7, 2023, 5:38 p.m.