Announcement

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

  • Opening SPSS files using stata - failure

    I am on Stata 16.1 and I want to convert SPSS files into .dta format. I have more than 30 SPSS files in one folder that needs conversion.

    I have been trying to 'import' it using the Stata inbuilt command and I also tried installing the user defined -usespss- for the purpose.

    The commands I used were the following:

    Code:
    import spss using "filename.sav", clear
    usespss "filename.sav", clear
    When I use the import command, I get the error "unable to parse file on disk" and when I use usespss command, it says "file not found".

    How do I write the command so that I can open the files?

  • #2
    Are you using the point and click interface to import the file available under "Import" in the "File" menu ? Please try doing the same and see if the issue persists.

    Comment


    • #3
      There are many possible explanations, including file corruption. Have you tried a different file?

      if you have Spss, it can export files in Stata format.

      The online rioweb is often great for simple file conversions.

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

      My first guess is file corruption, but hopefully not! Like Tarun says, make sure you have the command right. If you still can’t get Stata to do it, try a different means of converting the files.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

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

      Comment


      • #4
        The following info copied from the help for import spss gives some clues as to what might be wrong:

        Code:
        Description
        
            import spss reads into memory a version 16 or higher IBM SPSS Statistics (.sav) file or a
            version 21 or higher compressed IBM SPSS Statistics (.zsav) file.  import spss can import up
            to 32,766 variables at one time (up to 2,048 in Stata/IC).  If your SPSS file contains more
            variables than this, you can break up the SPSS file into multiple Stata datasets.
        Are the .sav files you are trying to import version 16 (of SPSS) or higher?

        On another tack, does this work for you?

        Code:
        clear
        import spss https://www.stata.com/sampledata/auto.sav
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment


        • #5
          Originally posted by Tarun Choudhary View Post
          Are you using the point and click interface to import the file available under "Import" in the "File" menu ? Please try doing the same and see if the issue persists.
          I tried both the point and click and writing it as a command. I get error in both cases.

          ​​​​

          Comment


          • #6
            Originally posted by Bruce Weaver View Post
            The following info copied from the help for import spss gives some clues as to what might be wrong:

            Code:
            Description
            
            import spss reads into memory a version 16 or higher IBM SPSS Statistics (.sav) file or a
            version 21 or higher compressed IBM SPSS Statistics (.zsav) file. import spss can import up
            to 32,766 variables at one time (up to 2,048 in Stata/IC). If your SPSS file contains more
            variables than this, you can break up the SPSS file into multiple Stata datasets.
            Are the .sav files you are trying to import version 16 (of SPSS) or higher?

            On another tack, does this work for you?

            Code:
            clear
            import spss https://www.stata.com/sampledata/auto.sav
            Yes!!! This works for me. Does that mean that the original SPSS file is at fault? I downloaded the survey dataset from the online university repository - I do not use SPSS - I only need to use Stata for this project (after the initial file conversion).

            Comment


            • #7
              You know that import spss does work but you still don't know why it isn't working with your file. It could be corrupted or it could be from an unsupported version of SPSS. Try the suggestions I made in post #3.
              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              StataNow Version: 19.5 MP (2 processor)

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

              Comment


              • #8
                Like Richard (in #3), I do wonder if there is a problem with the .SAV file. Can you ask the IT folks at your university to try opening the file with SPSS? If they cannot open it using SPSS, that supports Richard's speculation that the file may have been corrupted. If they can open it successfully, perhaps you can get them to export it to .dta format for you. HTH.
                --
                Bruce Weaver
                Email: [email protected]
                Version: Stata/MP 18.5 (Windows)

                Comment


                • #9
                  Thank you all! I deleted the entire SPSS folder and downloaded everything again. You were all correct. There was some corruption that I couldn't pinpoint.

                  Comment


                  • #10
                    I have exported data from spss into stata but I can not label values. Please help.
                    Attached Files

                    Comment


                    • #11
                      Stata does not allow value labels to be applied to string variables, but all of the variables you show above are of type string. Either the variables were strings in SPSS and remained as such when you exported them, or they were numeric variables in SPSS but something went wrong in the export. It is possible to make them into numeric variables in Stata using the -destring- command, but if it were me and had this problem with an export, I'd want to rerun the export. I don't have access to SPSS, so I can't advise about any problems there.

                      Comment

                      Working...
                      X