Timo Stolz
2008-Aug-19 14:17 UTC
[R] how to import from SPSS without shortening variable names
Hello, as I import '.sav' files from SPSS, the variable names are shortened to 8 uppercase characters: "sex_of_therapist" will become "SEX_OF_TH" Is there a way around this? How can I retrieve the full names? Greets from Southern Germany, Timo Stolz
Peter Dalgaard
2008-Aug-19 14:56 UTC
[R] how to import from SPSS without shortening variable names
Timo Stolz wrote:> Hello, > > as I import '.sav' files from SPSS, the variable names are shortened to > 8 uppercase characters: > > "sex_of_therapist" will become "SEX_OF_TH" > > Is there a way around this? How can I retrieve the full names? > >Well as long as it didn't become sex_of_the_rapist... This is actually changed in the most recent version of the foreign package, which is contained in R 2.7.2RC:> X <- read.spss("~/Desktop/Biobank_SPSS.sav", to.data.frame=TRUE)Warning message: In read.spss("~/Desktop/Biobank_SPSS.sav", to.data.frame = TRUE) : ~/Desktop/Biobank_SPSS.sav: File-indicated character representation code (1252) looks like a Windows codepage> names(X)[1] "Pt_id" "Popul" "Age" "Sex" "SKScode" [6] "Sys1" "Sys2" "Sys_pro" "Dia1" "Dia2" [11] "Dia_pro" "MAP1" "MAP2" "MAP_pro" "MAP_p" [16] "MAP_30_55" "Anaesthesia" "Efedrin" "Efedrin1" "Efedrin2" [21] "Metaoxedrin" "Nr" "ACE1" "ACE2" "ACE_ID" [26] "ACE3" "ACE4" "ADRA1A" "ADRA2A" "ADRB1_1" [31] "ADRB1_2" "ADRB2_1" "ADRB2_2" "ADRB2_3" "ADRB2_4" [36] "AGT_1" "AGT_2" "AGTR1" "GNB3" "AGTR2" [41] "GNAS" "NOS3_1" "NOS3_2" "NOS3_3" "ADRB2_5" [46] "ADRB2HA" "ADRB2HB" "ADRB2HP" "ADRB1HA" "ADRB1HB" [51] "ADRB1HP" "AGTHA" "AGTHB" "AGTHP" "ACEHA" [56] "ACEHB" "ACEHP" "H?jde" "V?gt" "BMI" [61] "BMIgroupA" "BMIgroupB" "BMIgroupC" So try the prerelease or wait till Monday (and miss the opportunity to have any bugs you find fixed before release). -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Prof Brian Ripley
2008-Aug-19 16:24 UTC
[R] how to import from SPSS without shortening variable names
On Tue, 19 Aug 2008, Timo Stolz wrote:> Hello, > > as I import '.sav' files from SPSS, the variable names are shortened to > 8 uppercase characters: > > "sex_of_therapist" will become "SEX_OF_TH" > > Is there a way around this? How can I retrieve the full names?Have you updated your 'foreign' package recently? I think that was changed in 0.8-27, and 0.8-29 is current. [sessionInfo(), which the posting guide asked you to paste in the output of, would have told us.] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595