Read SPSS file into R

后端 未结 14 1731
情歌与酒
情歌与酒 2020-12-12 14:17

I am trying to learn R and want to bring in an SPSS file, which I can open in SPSS.

I have tried using read.spss from foreign and s

相关标签:
14条回答
  • 2020-12-12 14:48

    I know this post is old, but I also had problems loading a Qualtrics SPSS file into R. R's read.spss code came from PSPP a long time ago, and hasn't been updated in a while. (And Hmisc's code uses read.spss(), too, so no luck there.)

    The good news is that PSPP 0.6.1 should read the files fine, as long as you specify a "String Width" of "Short - 255 (SPSS 12.0 and earlier)" on the "Download Data" page in Qualtrics. Read it into PSPP, save a new copy, and you should be in business. Awkward, but free.

    alt text,

    0 讨论(0)
  • 2020-12-12 14:52

    There is no such problem with packages you are using. The only requirement for read a spss file is to put the file into a PORTABLE format file. I mean, spss file have *.sav extension. You need to transform your spss file in a portable document that uses *.por extension.

    There is more info in http://www.statmethods.net/input/importingdata.html

    0 讨论(0)
  • 2020-12-12 14:52

    Turn your UNICODE in SPSS off

    Open SPSS without any data open and run the code below in your syntax editor

    SET UNICODE OFF.
    

    Open the data set and resave it to remove the Unicode

    read.spss('yourdata.sav', to.data.frame=T) works correctly then

    0 讨论(0)
  • 2020-12-12 14:53

    Another solution not mentioned here is to read SPSS data in R via ODBC. You need:

    1. IBM SPSS Statistics Data File Driver. Standalone driver is enough.
    2. Import SPSS data using RODBC package in R.

    See the example here. However I have to admit that, there could be problems with very big data files.

    0 讨论(0)
  • 2020-12-12 14:53

    For me it works well using memisc!

    install.packages("memisc")
    load('memisc')
    Daten.Februar <-as.data.set(spss.system.file("NPS_Februar_15_Daten.sav"))
    names(Daten.Februar)
    
    0 讨论(0)
  • 2020-12-12 14:57

    1)

    I've found the program, stat-transfer, useful for importing spss and stata files into R.

    It resolves the issue you mention by converting spss to R dataset. Also very useful for subsetting super large datasets into smaller portions consumable by R. Not free, but a very useful tool for working with datasets from different programs -- especially if you don't have access to them.

    2)

    Memisc package also has an spss function worth trying.

    0 讨论(0)
提交回复
热议问题