Announcement

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

  • save spss

    Somehow savespss is broken, random extra empty string variables are added to the file produced, like V25_0. And it doesn't support unicode. Why doesn't Stata offer export to spss itself?

  • #2
    The command -savespss- (SSC) was written by Sergiy Radyakin in 2014 when Stata 14 had not been released and Stata did not support Unicode.
    Svend Juul and Morten Frydenberg wrote command -unicode2ascii- which can help you perhaps (i.e. translate datasets and text files from Unicode to ASCII encoding, and then save as SPSS data files).

    Comment


    • #3
      Thanks, but I'm really looking for an automated way of producing spss files from stata without loss of, eg, variable labels or value labels.

      Comment


      • #4
        At least for now, Stata can import .sav directly, but cannot export .sav directly.

        Comment


        • #5
          Yep, indeed, the latter is the issue.

          Comment


          • #6
            Originally posted by Hendri Adriaens View Post
            I'm really looking for an automated way of producing spss files from stata without loss of, eg, variable labels or value labels.
            -unicode2ascii- does not remove that information. ascii refers to the encoding of the strings. A computer does not see a "a", it only knows 0s and 1s. In case of an "a" it sees 1100001. If the computer needs to show a character on your screen, than it consults a table and finds that 1100001 is an "a". This table is the encoding, it does not have anything to do with the presence or absence of variable labels or value labels. There are different "tables", ascii is one and unicode is another. -unicode2ascii- allows you to store your information contained in the variable and value labels using the extended ascii table instead of the unicode table, which would then supposedly work better with -savespss-.
            Last edited by Maarten Buis; 08 Nov 2021, 07:39.
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment


            • #7
              Ok, didn't check the package, assumed it would export things as a unicode text file, but see the real function now. Nevertheless, I'm using Stata 17 and the datasets I want to convert to spss are created using that version and hence are already unicode supported. The problem is that savespss doesn't generate unicode spss documents, and adds the empty variables. But yeah, it was created back in 2014, and it doesn't seem like there were changes more recently, so basically this package shouldn't be used anymore.

              So, I'm still hoping for a builtin function to export to spss, just as importing is possible nowadays.

              Comment


              • #8
                Hello Hendri. If you said why you want to export to .SAV files, I missed it. One reason might be so that SPSS users can use the data. If that is the only reason, SPSS users who have a relatively recent version can import .dta files very easily: They just have to choose Stata (*.dta) from a drop down list in the Open Data dialog. HTH.


                Click image for larger version

Name:	SPSS_import_Stata_dataset.png
Views:	1
Size:	117.8 KB
ID:	1635423




                Click image for larger version

Name:	SPSS_import_Stata_dataset_v2.png
Views:	1
Size:	57.6 KB
ID:	1635424
                --
                Bruce Weaver
                Email: [email protected]
                Version: Stata/MP 18.5 (Windows)

                Comment


                • #9
                  Yes, I know they can import it in spss, and that's exactly what I did now (manually) to create the spss files. However, we promised the users to give them spss files, so we will have to do that. With stata 16, there was no problem using savespss, although spss users would get a warning that the spss file wasn't unicode. But now savespss also generates spurious variables, the package has become useless for this purpose.

                  Comment


                  • #10
                    Coding is all about the details: we did not want you to turn your data into from ascii to unicode, but from unicode into extended ascii, because that is what savespss expects (as it was written prior to Stata 14).
                    ---------------------------------
                    Maarten L. Buis
                    University of Konstanz
                    Department of history and sociology
                    box 40
                    78457 Konstanz
                    Germany
                    http://www.maartenbuis.nl
                    ---------------------------------

                    Comment


                    • #11
                      Ok, the intention is to create unicode supported spss files without extra variables that magically appear in the produced spss file.

                      Comment


                      • #12
                        Originally posted by Hendri Adriaens View Post
                        Ok, the intention is to create unicode supported spss files without extra variables that magically appear in the produced spss file.
                        So your client has SPSS only, is that right? What version of SPSS does the client have? And what software do you have? Perhaps you should look into buying StatTransfer if this is the kind of thing you need to do on a regular basis. Alternatively, you might be able to do what you need using R's foreign package. (I am not a useR myself, so am just guessing about that.) HTH.
                        --
                        Bruce Weaver
                        Email: [email protected]
                        Version: Stata/MP 18.5 (Windows)

                        Comment


                        • #13
                          Yes, the users mostly only have spss. Stattransfer or any other external solution could be used indeed, as long as I can script it from Stata. I will look into those options once I have more time. Thanks for all suggestions!

                          Comment


                          • #14
                            Originally posted by Hendri Adriaens View Post
                            Ok, the intention is to create unicode supported spss files without extra variables that magically appear in the produced spss file.
                            You do realize that there is a difference between ASCII and extended ascii? Did you even try what we suggested ?
                            ---------------------------------
                            Maarten L. Buis
                            University of Konstanz
                            Department of history and sociology
                            box 40
                            78457 Konstanz
                            Germany
                            http://www.maartenbuis.nl
                            ---------------------------------

                            Comment


                            • #15
                              As I kindly pointed out in my previous reaction: I'm not after what you are suggesting or what unicode2ascii can do. But yes, of course I tried it, and indeed, spss still complains about the file format and indeed, savespss still creates the extra columns.

                              Comment

                              Working...
                              X