Discussion:
Moving data from SPSS to S-Plus
(too old to reply)
Julian Day
2006-02-21 11:10:56 UTC
Permalink
I have an SPSS data file which I want to analyse using S-Plus 6.2. All the
variables are of type "numeric", although some are really factors, as
specified in the "values" field. (E.g. "1.00" = patient; "2.00" = control.)
The variables that are really numeric also have some "values" specification
(e.g. "1000"= n/a).

If I read the data into S-Plus from a .sav or .por file, the factors behave
as they should, but the numerical variables end up as missing values, except
for those numerical values for which there was a "values" specification in
SPSS. I can instead go via .dat or .txt, in which case the variables are all
read as numeric, and I lose the labels attached to the factor variables.

What I want is to have the data as character vectors (or factors) where
there is an *exhaustive* list of "values" specifications in SPSS, but as
numerical variables when there isn't. There are a lot of variables, so I am
hoping to find a way of doing this that is not too labour intensive!

Julian Day
wintryheart
2006-02-22 03:12:26 UTC
Permalink
There is a good software--StatTransfer.
You can try it.
Robert Lundqvist
2006-02-22 09:26:47 UTC
Permalink
There is also a package for R called foreign (see
http://www.r-project.org/mirrors.html and look for "Packages") which makes
it possible to export files from other systems to R. Never tried it
though. And the export from R to S-Plus is not solved this way either, but
it *should* be simple, shouldn't it?

Robert
Eric B
2006-02-22 15:27:18 UTC
Permalink
one could always export the SPSS file into a .csv and then import that
into S-plus
wintryheart
2006-02-23 00:45:38 UTC
Permalink
Sometimes there are some errors when exporting the SPSS file into a
.csv, espcially the chaos of the data format.
Julian Day
2006-02-23 09:06:35 UTC
Permalink
Post by wintryheart
Sometimes there are some errors when exporting the SPSS file into a
.csv, espcially the chaos of the data format.
Thanks for all the suggestions.

I think I've found a reasonable work around. I save the data from SPSS as an
Excel spreadsheet, checking the box that says "Save value labels where
defined instead of data values". I then import this .xls file into S-Plus.
Unfortunately, you can only save a maximum of 256 variables at a time from
SPSS as an Excel spreadsheet; so I will have to split my data into two files
and then recombine them in S-Plus.

Julian
z***@yahoo.de
2006-02-23 10:51:32 UTC
Permalink
Hi Julian! I am using a simple function to import SPSS-data in R. It is
based on read.spss() from the foreign package and works fine. It seems
to import all labels. You just have to delete all multiple response
sets before you import (which you can´t use in R or SPlus anyways):

function (pfad=path)
{
## REQUIRES THE R-PACKAGES: foreign
## BE AWARE THAT ALL THE SPSS-INTERNAL MULTIPLE RESPONSE SETS HAVE BEEN
DELETED!!! Otherwise it doesn´t work, appearently.

daten<- read.spss(path, to.data.frame=TRUE, use.value.labels=FALSE)
names(daten)<-tolower(names(daten))
names(attributes(daten)$variable.labels)<-tolower(names(attributes(daten)$variable.labels))

daten
}


Good luck!

Michael
Frank E Harrell Jr
2006-02-23 16:52:18 UTC
Permalink
Post by z***@yahoo.de
Hi Julian! I am using a simple function to import SPSS-data in R. It is
based on read.spss() from the foreign package and works fine. It seems
to import all labels. You just have to delete all multiple response
function (pfad=path)
{
## REQUIRES THE R-PACKAGES: foreign
## BE AWARE THAT ALL THE SPSS-INTERNAL MULTIPLE RESPONSE SETS HAVE BEEN
DELETED!!! Otherwise it doesn´t work, appearently.
daten<- read.spss(path, to.data.frame=TRUE, use.value.labels=FALSE)
names(daten)<-tolower(names(daten))
names(attributes(daten)$variable.labels)<-tolower(names(attributes(daten)$variable.labels))
daten
}
Good luck!
Michael
The spss.get function in the Hmisc package for R, which also uses
read.spss, may make this a bit easier, and it associates variable labels
with individual variables.

Frank Harrell

Continue reading on narkive:
Loading...