Function to write an SPSS por file. Returns an por file that read.por can read as well as SPSS can. Other packages as foreign, memisc and haven might fail (fail reading or return wrong values).

write.por(
  dat,
  filepath,
  label,
  add.rownames = FALSE,
  convert.factors = TRUE,
  toEncoding = "CP1252",
  convert.dates = TRUE,
  tz = "GMT"
)

Arguments

dat

data.frame a data.frame to export as por-file.

filepath

string full path where and how this file should be stored

label

character vector of labels. must be of size ncol(dat)

add.rownames

logical If TRUE, a new variable rownames will be added to the por-file.

convert.factors

logical If TRUE, factors will be converted to SPSS variables with labels. SPSS expects strings to be encoded as Windows-1252, so all levels will be recoded. Character which can not be mapped in Windows-1252 will be saved as hexcode.

toEncoding

character encoding used for the por file. SPSS itself claims to have problems with unicode and por files, so "CP1252" is the default.

convert.dates

logical should dates be converted to SPSS format

tz

character The name of the timezone convert.dates will use.

Value

write.por returns nothing

Details

Strings longer than 255 chars are not provided. File will be stored using "CP1252" encoding.