Working on a little primer to ease the transition from SPSS to R, I have
encountered two problems with write.foreign.
One is cosmetic (but still annoying): the text data files will contain
"NA" for missing values. Each time SPSS encounters an NA, it will print
a warning. This could be easily avoided by calling write.table (which I
suppose write.foreign uses) with na=",,". That's right, two commas.
The second is more serious: character variables are not read at all
because they are not specified correctly in the SPSS syntax file. A
string variable has to be specified with a preceding asterisk and a type
and length indicator. Suppose mydf contained a numerical variable "a"
and a string variable "b" with max(nchar(mydf$b))==10. What
write.foreign(mydf,...,package="SPSS") writes is: