- I have.sav file and i need to convert it into csv file. I tried to use import savReaderWriter library but its not working. I am getting this error: SPSSIOError: Problem opening file b'C: Users I know in R it might be easier but i really need in Python.
- How to open SAV files You need a suitable software like Saved File to open a SAV file. Without proper software you will receive a Windows message 'How do you want to open this file?' (Windows 10) or 'Windows cannot open this file' (Windows 7) or a similar Mac/iPhone/Android alert. If you cannot open your SAV file correctly, try to right-click.
- Start by opening a SPSS dataset. You start SPSS and select the Open and Data options from within the File menu: Change the 'Look in:' window until it points to the desired directory location. You should see a list of SPSS datasets (.sav) files within that directory. We will be opening the file named 'Winter2000.sav'.
Another very simple method to open an SPSS file into R is to save the file in a format which R manage very well: the dat format (tab-delimited). So, you save your SPSS file in.dat and you behave as before, searching the file with file.choose and assigning the resulting string to an object. The function to read the file, now, is read.table.
This tutorial explains how to import data from Excel into the SPSS statistics package.
Preparing Excel
Open the Excel spreadsheet from which you wish to import data.
![How How](/uploads/1/1/9/4/119460123/603967277.gif)
You can see in our example that we have 5 columns of data.
Before you begin the process of importing your data into SPSS, you need to ensure that your variable names are in the first row of the worksheet, and that there is no gap between the first and second rows. Our worksheet satisfies both these requirements.
It’s also wise to clean up your data. For example, if you had coded one of the Frisbee Throwing Distance items as “50m” rather than just “50”, this would be a good time to make a correction.
Once you have got your worksheet straight, you can open up SPSS.
Importing Data from Excel into SPSS
There are a number of different ways to import data into SPSS. We’re going to use a method that allows backward compatibility with older versions of SPSS. Adobe illustrator for mac os x 10.9.55.
To start, click File -> Open -> Data (as below).
Once you click Data, the Open Data box will appear.
In the Files of type box, you need to select Excel (see 1 above, though obviously things will look slightly different if you’re using a Mac). Then navigate to the folder that contains your Excel file, and you’ll see your Excel file pop up (see 2 above). Open the file, and you’ll get the Read Excel File dialog box.
Read Excel File Dialog Box
This dialog box offers a number of options. Mainly these are self-explanatory, but it is probably worth explaining the “Percentage of values that determine data type” option. This is how the latest version of SPSS assigns a data type to your variables. The percentage is the proportion of values in a particular column that must match a specific data type for SPSS to assign that data type to a variable. In our example, a variable will be assigned to a particular data type if 95% of values match that type (for example, if 95% of values are numeric in form). The value can be any number above 50. If SPSS is unable to determine a data type on this basis it will assign the variable to a string type.
How To Open Spss File In Excel
Once you’ve selected the options you require, and checked your data looks okay in the preview window, press OK to begin the import.
Check Your Data Within SPSS
SPSS will import your data into a new Data View with variable names at the top.
Obviously, the first thing to do here is to check that the data has come across successfully. If everything looks okay, the next stage is to check whether the various data parameters have been set correctly. Is numerical data correctly set as numerical, for example?
To check this, click on the Variable View tab (see red arrow, above). This will bring up the variable view within SPSS.
Variable View
As you can see from the image below, SPSS did a good job with our sample data, correctly identifying SubjectID, Gender, DogOwner and FrisbeeThrowing as data type numeric, and Education as data type string.
It also got level of measurement correct (see the Measure column), identifying SubjectID, Gender, Education and DogOwner as nominal data, and FrisbeeThrowing as scale (that is, as interval/ratio data).
***************
That’s pretty much it for this tutorial. You should now have a good idea of how to import data from Excel into the SPSS statistics package.
***************
EZSPSS on YouTube
We have a video tutorial that covers this same material in slightly more detail. Check it out!
SPSS data sets
If you have read data from a different format than SPSS, or if you have modified an existing SPSS file, you may wish to save your file for further use in SPSS format. This is done with the
SAVE FILE
command.Example:
SAVE OUTFILE = 'd:mydirectorymysubdirectorymydata.sav'.
How To Open Spss File
where you have to fill in your directory and data set names. Note that SPSS issues no warning if you overwrite an existing data set, thus be careful in the choice of the name of this data set. Of course, if you have modified an existing data set, using the old name may be exactly what you want. However, this should only be done if you have augmented your data set, i.e. if you have added new variables. If you have changed, or even deleted, old variables, as a beginner you should use a different name for your data set even if you have changed or deleted these variables precisely because you wanted to get rid of them. But perhaps you have committed a mistake and wish to redo your modifications in a different way; this will be impossible if the original variables have not been kept somewhere.
As with the
GET FILE
command, the KEEP, DROP
and RENAME
subcommands are available to change your data file during the SAVING process. If you want to get rid of most of your variables, it is useful to indicate which variables you want to KEEP; if you want to keep most of the variables, you will prefer to indicate which variables to DROP. Renaming variables can be useful for various purposes. Here's an example:SAVE OUT = 'd:mydirectorymysubdirectorymydata.sav' | |
/ DROP var11 var15 var17 var88 | |
/ RENAME (var10 var19 = gender age). |
Note that SAVing your data file does not affect your working file. Thus, if you wish to use the SAVed data set for your next analysis steps, you first have to read in the file anew with the
GET FILE
command. This may happen more frequently than you think; for instance, you may have modified your data, and in the process a number of 'intermediate' variables may have been used which are not of interest by themselves, but were needed in one way or other for creating new variables of interest. (For instance, you may wish to compute the overall household income from different types of income of several persons in a household; this may easily amount to hundred variables or more.) But when you have finished your task, these variables are no longer useful and only render your data set unnecessarily large. This is the moment when it is a good choice to SAVe your data and DROP
those variables you don't need any longer (or to KEEP
those with which you wish to pursue your work).Saving your data in another format
For some reason or other, you may wish to analyze your data with other software. This 'other software' may be able to read SPSS data, but much more frequently than not this is not the case. SPSS can assist you by saving the data either in a specific format or in a general format that can be read by most software.
Here is a small selection of possibilities.
Saving data as a Stata™ file
SAVE TRANSLATE OUT = 'd:mydirmystatadata.dta' | |
/ TYPE=STATA | |
/ VERSION=8 | |
/ EDITION=SE | |
/ DROP var17 var20 var24 | |
/ REPLACE. |
REPLACE
will do what it looks like doing, i.e. any existing file with the same name will be overwritten. Of course, you may omit this command.Open Spss File Online
Saving data as a comma delimited file
In this type of file, the data will be in 'raw' format, with each data value separated from the next by a comma. This may be read by a variety of other software.
SAVE TRANSLATE OUT = 'd:mydirmycsvdata.csv' | |
/ TYPE=CSV | |
/ MAP. |
MAP
will produce an exact list of all variables written to the new file. Of course, the DROP
and KEEP
subcommands may be used as well. Saving data as a tabulator delimited file
Use the same command as with a comma delimited file, but use
TYPE=TAB
instead. Saving data in a plain ASCII file
To save your data just as raw data and nothing else (no delimiters, no other characters), the command goes like this:
WRTIE OUT = 'd:mydirmyasciidata.txt' TABLE | |
/ var1 var17 var18 to var24. | |
EXECUTE. |
If you just wish to
WRITE
the entire data set, use ALL instead of a varlist.Open Sav File Online
This procedure will produce an ASCII file in FIXED FORMAT (see section Read Raw Data on how to read such a file). Keyword
TABLE
will make SPSS produce an exact description of the data set. Note that WRITE
will be accomplished only upon execution of another command or with the help of EXECUTE
, as demonstrated here.© W. Ludwig-Mayerhofer, IGSW | Last update: 16 Sep 2009