Announcement

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

  • converting dataset to SPSS

    I am trying to convert a dataset from stata to SPSS for a colleague who uses SPSS. I have not had issues before using the savespss function. When trying to do it this time I received the following message:
    _savespss_checkvars(): 3333 Variable names duplicates due to case-insensitivity of SPSS: Decline
    savespss(): - function returned error
    <istmt>: - function returned error

    Can anyone advise on what to look for or change in the dataset so that I can convert it?

    Thanks!
    Jessica


  • #2
    I've not used SPSS in the current millennium, but I'll take a guess here. Let's imagine a dataset with variable names frog and FROG which would be problematic if both were cast to upper case. We just look for duplicates therefore in the list of upper-cased names. You could do this the other way too, by looking for duplicates in lower-cased names.


    Code:
    clear 
    set obs 1 
    foreach v in frog FROG toad newt { 
         gen `v' = 42
    } 
    
    ds
    local names "`r(varlist)'" 
    local NAMES 
    
    foreach v of local names { 
         local NAME = strupper("`v'") 
         local NAMES `NAMES' `NAME' 
    } 
    
    . di "`: list dups NAMES'" 
    FROG
    You might get away with

    Code:
     
    local NAMES = strupper("`names'")

    Comment


    • #3
      I don't use it either! Turns out SPSS can just open the .sav datafile and will add a suffix to any that are duplicates. Thanks!

      Comment


      • #4
        you meant ".dta" datafile, but yes, SPSS (and SAS and R) can all read Stata data.
        Doug Hemken
        SSCC, Univ. of Wisc.-Madison

        Comment


        • #5
          I'll repeat my usual advice that Stat/Transfer is a fantastic purchase, even if you only use it a few times a year. If you have more time than money you can usually find a cheap workaround, but it may take you a while to learn it and apply it.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

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

          Comment


          • #6
            In my experience, Stat/Transfer often does a more efficient (compact) job of converting than the internal routines of the various software programs. This is especially an issue when pulling things into Stata or R, not so much when putting things to SPSS or SAS (both of which default to 8 byte doubles).
            Doug Hemken
            SSCC, Univ. of Wisc.-Madison

            Comment


            • #7
              For anyone else receiving the error message that Jessica has quoted, it means exactly what it says: there are variables in your data which differ only by case (for example ABC and abc), which is allowed in Stata, but not allowed in SPSS. Clearly the SPSS file can't be produced. Simply rename them the way you want, and re-run the data export command. The command savespss reports the name of the variable which is causing the problem in the error message.

              In Jessica's example it is a variable Decline, which coincides with some other spelling like "decline" or "DECLINE" or something else in her data. The recommendation is to rename it to something like Decline0 and retry.

              Best, Sergiy Radyakin

              Comment

              Working...
              X