4

A friend is in search of a method to translate SPSS 'syntax' files to semantically equivalent R source code files.

I suppose, no one ever wrote a translator. But maybe I'm wrong.

PS: Please excuse the wrong use of 'syntax': People using SPSS tend to name an SPSS source program a 'syntax file' ;-)

SteAp
  • 11,853
  • 10
  • 53
  • 88
  • You may want to ask on the stats.stackexchange.com site – Joe Phillips May 08 '11 at 00:45
  • @Joe Philllips: Thanks for point out! I'll probably do later on. I hope to get 'more technical' answers here. May I keep it open? – SteAp May 08 '11 at 00:50
  • 1
    @Joe, why did you recommend CrossValidated? IMHO this is solely a technical question. =/ @Stefan, AFAIK, there's no such thing. It would take ages to implement such a feature... =( – aL3xa May 08 '11 at 01:23
  • 3
    If you haven't seen it, check out http://sites.google.com/site/r4statistics/the-books/r4sas-spss – Chase May 08 '11 at 02:58
  • If such a thing existed it would be located at developer central (check out the SPSS tag wiki for links, http://stackoverflow.com/tags/spss/info). I doubt it exists though, as aL already aluded to. – Andy W May 08 '11 at 04:48
  • @aL3xa Because that is where you will find the experts that likely know how to answer this question – Joe Phillips May 08 '11 at 07:12
  • I have briefly considered writing an import module for SPSS files (i.e. .sps + .asc file combination), since I receive this occasionally as input files. However, in practise it is always easiest to go back to source and request an SPSS export file (i.e. .sav file). The `read.spss` function in package `foreign` deals with this very well. – Andrie May 08 '11 at 16:19
  • Thank you to all who commented! I'd be happy to keep this question at this location open for some days. I too expect, that no translator exists. BTW: A solution would be a great business case. – SteAp May 08 '11 at 18:49

3 Answers3

4

The short answer is that sorry, you are right, there is no tool for automatically translating SPSS script to R script. Even worse, such a tool would likely take several (many?) man-years to create, so don't hold your breath.

A small concession is that it is probably not to hard to create a tool for translating very small, specific subsets of SPSS to R. For example, if you have a chunk of code for reading in CSV files, then you could use regular expressions to extract the useful bits from the SPSS code and autogenerate some R code from them. In most instances however it will be far easier and faster to manually port the code yourself.

If all else fails, ask Bob Muenchen; he know a lot about porting SPSS to R.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
3

Another option for this is SPSStoR, which claims to be able to translate many common (but basic) SPSS procedures to R code. It seems to be under active development on GitHub as of August 2014.

Thomas
  • 43,637
  • 12
  • 109
  • 140
2

I know it's been more than 3 years after the question was originally asked, but it's worth noting that a German company by the name of eoda is actually working on such software. It's called translateR. It is currently in beta status and you can register for a beta test on their website.

Wolfgang
  • 2,810
  • 2
  • 15
  • 29