Hello,

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:

DATA FILE filename.dat free
/ a b.

What it should write, however, is:

DATA FILE filename.dat free
/ a * b (A10).

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to