Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata to SPSS data convertion

    Dear Stata user,
    I have happily used tremendous Stata which is excellent in data management but in my new working station people use SPSS extensively. I have to move Stata to SPSS and SPSS to Stata. I know how to manage data from SPSS to Stata but Stata to SPSS stuck me. I have searched in google, not able to find any method rather than Stat transfer software data conversion which have to buy. I have tried in SPSS but problem is I'm using Stata 13 and SPSS 20 so can't convert the data set.
    Is there any written package available (using above mentioned version) for data conversion from Stata to SPSS?
    or can I convert Stata 13 data to Stata 9 using any package that may help to read data in SPSS?

    Note: I don't want to convert it into Excel way cause these way i'll loose variable value label.
    Last edited by Rayhan Islam; 12 Oct 2017, 02:12.

  • #2
    Don’t remember if the saveold command was available in Stata 13, but that may be a viable option to save to an earlier version of the Stata file format.

    Comment


    • #3
      saveold is in Stata 13. It won't save to version 9. This is the definition in the help:


      Code:
       Save data in memory to file in Stata 12 format
      
              saveold filename [, saveold_options]

      Comment


      • #4
        I used saveold command for Stata 13 but that only convert to Stata 12 so not feasible to read in SPSS. SPSS support Stata 9 or older version.

        Comment


        • #5
          try stattransfer (http://stattransfer.com/)

          Comment


          • #6
            Convert your value labels to strings with "decode", transfer as a CSV file, then in SPSS use "autorecode".

            To go the other way, in SPSS use "compute" with the "valuelabels()" function, transfer via CSV, and in Stata use encode.

            For the variable labels you will need to generate code: there are macro functions in Stata that will let you get at this; in SPSS you would write a program in Python.

            StatTransfer will be worth the money if you have to do a lot of this! Or just learn to do data management in the language your colleagues use. Your knowledge of Stata concepts will enable you to learn SPSS quickly. The main difference in data management is that you work row-wise instead of column-wise ... and you gain the ability to work with multiple data sets more easily.

            SPSS also has **extensive** capability for formatting output tables
            Last edited by Doug Hemken; 12 Oct 2017, 05:33.
            Doug Hemken
            SSCC, Univ. of Wisc.-Madison

            Comment


            • #7
              Hi Rayhan,

              Sergiy Radyakin wrote a program for Stata called -savespss-. I have good experiences with using it; you can read more about it and find download instructions on Sergiy's website.

              I only encountered two issues with it:
              1. On large Stata datasets, especially with very large value-label sets, it can get kind of slow.
              2. It does not convert Stata characteristics to SPSS data attributes (which even Stat/Transfer does not do, nor the Stata-import routines within SPSS).
              If these two are not a problem for you: Have a look at it.

              Kind regards
              Bela

              Comment


              • #8
                Doug's suggestion is good. Let's spell out how to do the first part in Stata.


                Code:
                ds, has(vallabel)
                local todecode `r(varlist)' 
                foreach v of local decode  {
                    decode `v', gen(`v'_dd)
                    _crcslbl `v'_dd `v' 
                }
                drop `todecode' 
                rename *_dd  *
                There are some assumptions in there, such as

                1. The suffix _dd not being in use previously.

                2. Names being short enough that you can add _dd

                Comment


                • #9
                  I would try -savespss-. Or I would splurge and get Stat/Transfer. But this free site may meet your needs if nothing else does:

                  https://gallery.shinyapps.io/rioweb/

                  If you are an R user (or willing to become one) it has a lot of free import and export/ conversion routines. For example, I just tried this in R:

                  Code:
                  library(rio)
                  convert("C:/Dropbox/statafiles/401kpart.dta", "C:/Dropbox/statafiles/401kpart.sav")
                  It seemed to work ok, but since I don't have SPSS installed I can't really say. It worked ok the other way, with this command producing a Stata 14 file:

                  Code:
                  convert("C:/Dropbox/spssfiles/401kpart.sav", "C:/Dropbox/spssfiles/401kpart.dta")
                  I think Stat/Transfer is the way to go if you don't mind spending a little money and have frequent file conversion needs. But, the cheap free stuff that is out there may be worth trying.
                  -------------------------------------------
                  Richard Williams, Notre Dame Dept of Sociology
                  Stata Version: 17.0 MP (2 processor)

                  EMAIL: [email protected]
                  WWW: https://www3.nd.edu/~rwilliam

                  Comment


                  • #10
                    I agree to Richard Williams that a free solution, possibly involving R, would be great. However, all R packages I tried [haven, foreign and rio (which itself uses haven to read/write SPSS and Stata files), that is] lack to convert Stata notes (and any other type of characteristics) to SPSS notes (and any other type of data attributes), and vice versa. So, at the time of writing, a full solution for the problem -- as far as I know -- does simply not exist.

                    Regards
                    Bela

                    Comment


                    • #11
                      Good to know about the R limitations. I rarely use notes or characteristics so I don't think it would matter much to me but it may for others. Based on its web page, it looks to me like savespss is the best free solution:

                      http://www.radyakin.org/transfer/savespss/savespss.htm

                      Of course, if you didn't have Stata you'd have to use something like one of the R freebies or break down and get Stat/Transfer.
                      -------------------------------------------
                      Richard Williams, Notre Dame Dept of Sociology
                      Stata Version: 17.0 MP (2 processor)

                      EMAIL: [email protected]
                      WWW: https://www3.nd.edu/~rwilliam

                      Comment


                      • #12
                        Daniel Bela, moving Stata dataset notes to SPSS documents or dataset attributes, and moving Stata variable notes to SPSS variable attributes is going to require dumping/importing things into files (datasets) and macro processing in each language (in SPSS that would likely be Python). Sounds like a real coding challenge.
                        Doug Hemken
                        SSCC, Univ. of Wisc.-Madison

                        Comment


                        • #13
                          I was just looking at the Stat/Transfer, and I'm not seeing anything about variable attributes and notes. Maybe it handles them fine -- but do we know for sure that a program exists that handles Daniel's concerns?
                          -------------------------------------------
                          Richard Williams, Notre Dame Dept of Sociology
                          Stata Version: 17.0 MP (2 processor)

                          EMAIL: [email protected]
                          WWW: https://www3.nd.edu/~rwilliam

                          Comment


                          • #14
                            What happens when Stata datasets with strL variables are exported anywhere else? The wider point is that many programs have ideas on data that don't necessarily correspond to anything in any other program. This not to deny that people who use StatTransfer seem very happy that it solves almost all their problems.

                            Comment


                            • #15
                              I use STATA 14 and want to convert a dataset to SPSS version 24. Is there any packages or codes available in STATA 14 or is the software stattransfer still recommended?

                              Comment

                              Working...
                              X