Announcement

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

  • Issues with accented characters import spss

    Hello everyone,

    I need to import a .sav type file in Stata to work with it. Moreover, I am not interested in all the variables inside this .sav file and I'd like to import just a subset of them.

    My problem is: one of the variables I am interested in has an accent in the name and when I try to import the file I get the error "invalid syntax" (r198).

    This is the code I am running:

    import spss var1 var2 età using "myfile.sav"


    How can I solve this problem?

    Alternatively I could run:

    import spss using "myfile.sav"

    and then keep only the variables I am interested in, but since the file is quite big and I need to loop over 20 of these files it would take ages.

    Thanks in advance for your attention,
    Kind regards

    Federico.

  • #2
    Possible bug, contact https://www.stata.com/support/tech-support/contact/

    Comment


    • #3
      Originally posted by Federico Stronati View Post
      How can I solve this problem?
      Seems to be a bug. Reproducible here:
      Code:
      version 18.0
      
      clear *
      
      quietly set obs 1
      
      forvalues i = 1/2 {
          generate byte var`i' = 1
      }
      
      generate byte etá =1
      
      quietly export spss using myfile
      quietly export excel using myfile.xlsx, sheet(myfile) firstrow(variables)
      quietly save myfile
      
      drop _all
      use var1 var2 etá using myfile
      
      drop _all
      quietly import excel var1 var2 etá using myfile.xlsx, sheet(myfile)
      
      drop _all
      capture noisily import spss var1 var2 etá using myfile.sav
      
      erase myfile.sav
      erase myfile.xlsx
      erase myfile.dta
      
      exit
      I tried using the GUI for importing and that's even weirder (and equally unsuccessful). I didn't expect it would, but unicode translate didn't help either, at least when using my guess for encoding.

      I recommend reporting this to StataCorp Technical Support.

      If you're in a hurry, you could look into Stat/Transfer. It's not free, but I've confirmed that it does work in this case even when specifying a variable subset.

      Comment


      • #4
        Dear Bjarte Aagnes and Joseph Coveney,
        thanks a lot for your answers. I'll report it to the StataCorp Technical Support. Very useful also the tip with Stat\Transfer!

        Thanks again, best regards
        Federico

        Comment

        Working...
        X