[R] SPSS long variable names

Robert Baer rbaer at atsu.edu
Thu Oct 15 21:02:37 CEST 2009


>>>>> The problem is the limit of 8 characters long on variable
>>>>> names.[in read.spss??????]
I just created a file in SPSS 17 and saved it in standard format (.sav) The 
file had four unique variable NAMES which were much longer than 8 characters 
(although not 64).  I entered two rows of data and saved the file again. 
The "variable view" in SPSS looked like the following for the 4 variables I 
created.  (unique in the first postition after the first 9)

a12345678901234567890987654321098765432011111111111111 Numeric 8 2 
a1234567890 None None 14 Right Scale
a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 
Right Scale
a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 
14 Left Nominal
a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 
14 Right Scale

I now started R and used read.spss() from the foreign package using the 
following code"  The data frame I read in seemed to reflect the original 
file with respect to column names:

>library(foreign)
> c=read.spss(file.choose(),to.data.frame=TRUE)
> c
  a12345678901234567890987654321098765432011111111111111 
a1234567899123456789098765432109876543201 
a1234567898123456789098765432109876543201
1                                                   33.3 
13452825600                                  a cat
2                                                   22.2 
13463280000                                  dog
  a1234567897123456789098765432109876543201
1                                     32165
2                                 321654987

It appears these long variable names read in just fine.  Thus, I would ask 
caveman whether the problem is really an R problem at all, or is it a 
problem with PSPP writing (in which case this would be the wrong list to be 
discussing it on)?

R




More information about the R-help mailing list