• "Everything should be made as simple as possible, but not simpler." - Anonymous (although often attributed to Albert Einstein)
  • Enter your email address to subscribe.

  • Categories

  • Recent Comments

  • RSS Statalist: the Stata forum

  • RSS Stackoverflow [Stata]

  • Google Analytics Stats

    Period:Last 30 Days
    Total Visits:10348

Reading SPSS data file into Stata


Is it possible to open an SPSS file (*.sav) directly from Stata? Yes. Thanks for the program -usespss- written by Sergiy Radyakin of the World Bank, which loads a *.sav dataset into Stata preserving variable names and labels. Since -usespss- is user-written, you need to install it first from the Statistical Software Components (SSC) archive, which is Stata’s download site for user-written programs. Installing files from SSC is made easy by using the -ssc install- command; but if you want to read the description of the program first before installing, you may use the -ssc describe- command:

ssc describe usespss
/* Provides a description of the program -usespss */
ssc install usespss
/* Installs -usespss- into Stata */

You can now use -usespss- after installation. The basic syntax for -usespss- (for the full syntax, type: “help usespss”) is:

usespss using filename.sav [, clear saving(filename) iff(condition) inn(condition)]

For example:

usespss using filename.sav
/* loads filename.sav into Stata memory */

usespss using filename.sav, clear
/* clears the existing data in memory and loads filename.sav */

usespss using filename.sav, saving(filename.dta)
/* loads filename.sav and saves it as a Stata file filename.dta */

usespss using filename.sav, clear inn(1/50)
/* loads the first 50 observations in filename.sav */

usespss using filename.sav, clear iff(var1<1000)
/* loads the observations in filename.sav that satisfy the condition var1<1000 */

[Note: The -iff- and -inn- options work in same manner as the Stata qualifiers -if- and -in-, respectively. We have showed some examples how the qualifiers -if- and -in- are used in "Putting observations in order" and "_n _N and bysort."]

Another way to convert an SPSS to Stata data is to use the software called Stat/Transfer. Or, if you have SPSS, you may save the data as a Stata-formatted file.

7 Responses

  1. I’m trying to install this package using the command below:

    ssc install usespss

    but I get this answer:

    nothing to install

    Any idea of what might be happening ? I just installed Stata 11 IC in my computer so the entire environment is a bit new for me

    Thanks a lot

    Roberto

  2. Hi Mitch! How do you access spss files using 64-bit Stata? If that is not possible, how do I shift from 64-bit to 32-bit? I’ve re-installed Stata in my laptop and chose 32-bit but the license is for 64-bit so I cannot open Stata using 32-bit. Hope you can help me. Thanks!

    Shanna

  3. Hi Mitch! I have tried stat transfer but some values are truncated. Is there no other way? o *.csv na lang para infix?

    Shanna

    • Check why the values are truncated. Knowing a little bit about the data you are working on, I am guessing that these are the very long IDs that are coded as numeric, but are better off as strings.

Leave a Reply

%d bloggers like this: