Sunday, June 17, 2012

3 Ways of Loading SPSS (sav) files into Stata

1. The easiest and most straightforward way is using the user written package usespss.

  This package however only works for 32 bit windows.

2. The next easiest method if you have it available is using StatTranfer which allows for the conversion of many types of files from one format to another:

  A license could be had for as little as $59 if you are a student.


3. The last option takes a few more steps but is free.

  a. First install R

  b. Next install the package Rcmdr from the Package Menu by selecting "Install Packages" [Packages>Install Package(s)>Select Closest Mirror>Rcmdr].

  c. Next open up the Rcmdr package by going to the menu [Packages>Load Package...>Rcmdr]

 d. When Rcmdr loads it should load the R Commander window.  Select from the menu [Data>Import Data>from SPSS data set]

 e. Name your data set Data1 [select 'ok'], now find your sav file.

 f. If there has been no problem up to this point you should now have a data set in memory called Data1.

 g. Now you can export to a dta file with the following command:
write.dta(Data1, "File Directory/File Name.dta")

(In R you need to specify directory dividers as either / or \\ not \.)

10 comments :

  1. You can do the R method as an ado file (at least on Mac/Linux, not sure about Windows)
    http://codeandculture.wordpress.com/2010/06/29/importspss-ado-requires-r/

    ReplyDelete
  2. Does the R method actually translate the SPSS code to STATA code?

    ReplyDelete
  3. Note that you can also save an SPSS data file as a Stata data set, if you have SPSS.
    If you don't, and just have the .sav file, then one of the above methods would work.
    I would never have thought about going through R!

    ReplyDelete
  4. Thanks a lot for the simple description of the steps in R, works flawlessly for me!

    Cheers

    ReplyDelete
  5. Thanks for detailed descpirtion, it worked fine for me, even I had no idea what R is.
    I had a little problem on my way as i wrote a new .dta file name, but I have solved it by creating a mini .dta file with two first variables from SPSS file and then repeating export from R to that .dta file.
    For them, who want to create a new STATA file with data from SPSS file, the first step should be to create a .dta file nad then write to that file.

    ReplyDelete
  6. Thanks a lot :-) R worked for me too. All the best

    ReplyDelete
  7. Good job! Note that there is a new version of -usespss- that works in 64-bit Stata (Windows only), with the additional advantage of not losing variable labels (unlike with the R method, as far as I know). It's a beta, but has worked flawlessly for me so far, see

    http://radyakin.org/transfer/usespss/faq/usespss_faq.html

    ReplyDelete