[R] SPSS long variable names

joris meys jorismeys at gmail.com
Wed Oct 14 17:31:13 CEST 2009


On Wed, Oct 14, 2009 at 2:45 PM, Robert  Baer <rbaer at atsu.edu> wrote:
>>>>>> The problem is the limit of 8 characters long on variable
>>>>>> names.
>
> And again, my answer is that one approach would be to map SHORT names to
> long variable LABELS.  This was a common use of labels before variable names
> supported 64 bytes.  After reading into R with read.spss() you and easily
> replace the short R names with the long LABELS to form long R names.
>
> If for for some reason you are unwilling to give up some existing LABELS
> that are not, you could create some dummy variables for just this mapping
> purpose.
>
Dear Robert,

the problem with this approach is that :
1) if the first 8 characters of some variable names in the SPSS
dataset are the same, you'd get confusing results. Mapping the labels
on the short names might get complicated too, although I'm not sure on
that.

2) data labels can contain spaces (and often do), so they cannot be
readily used as variable names in R.

Cheers
Joris


> ----- Original Message ----- From: "Orvalho Augusto" <orvaquim at gmail.com>
> To: "Robert Baer" <rbaer at atsu.edu>
> Cc: <r-help at r-project.org>
> Sent: Tuesday, October 13, 2009 10:39 AM
> Subject: Re: [R] SPSS long variable names
>
>
>> No!
>>
>> That is variable labels.
>>
>> Caveman
>>
>>
>> On Tue, Oct 13, 2009 at 4:52 PM, Robert  Baer <rbaer at atsu.edu> wrote:
>>>>>
>>>>> I am wondering if there is a patch for the SPSS reading
>>>>> code on the
>>>>> foreign package, in order to be able to read long variable
>>>>> names.
>>>>> Right now read.spss() just trunc the names to 8
>>>>> characters.
>>>
>>> This sequence seems to access the long filenames for me if I know what
>>> you
>>> are asking for:
>>>
>>> library('foreign')
>>> a<-read.spss('fil.sav')
>>> lnames <- attr(a,"variable.labels",exact=FALSE)
>>>
>>> Rob
>>>
>>>
>>>
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list