Announcement

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

  • #16
    You might see if the free Rioweb will do what you want:

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

    If it does but you want something that can be called from within Stata, you could probably write a simple R program that Stata calls.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 18.5 MP (2 processor)

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

    Comment


    • #17
      Hendri wrote:

      Yes, the users mostly only have spss.
      I must be missing something. Why can you not simply give the clients .dta files?

      As I noted in #8, SPSS can directly open .dta files. The only problem I can think of is clients having (quite) old versions of SPSS that do not support that feature. As the link below shows, GET STATA was added in SPSS 14, and the ENCODING sub-command was introduced in SPSS 19. The current version is SPSS 28, so I suspect most clients will have a new enough version to import .dta files directly. Thanks for clarifying why giving clients .dta files is not an option!
      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 18.5 (Windows)

      Comment


      • #18
        Originally posted by Hendri Adriaens View Post
        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?
        1. Somehow savespss is broken,

        Kindly, demonstrate this with a transparent and reproducible example, such as a single do-file, which constructs the dataset using input/generate/etc statements that we can all understand and trace. Have a side-by-side comparison of what you are seeing in Stata and what you are getting in SPSS, as well as clearly present the syntax of the commands you've called (in both systems).

        2. random extra empty string variables are added to the file produced, like V25_0

        They are not random, and the theory behind them is rather complex, but pretty much anyone will see them in a very old version of SPSS, as they are being used for compatibility with older versions, but newer versions shouldn't display anything confusing (if you are using SPSS 16 or later that shouldn't bother you, for earlier versions, may need to look this up).

        3. And it doesn't support unicode.

        Chen Samulsion has mentioned immediately that the -savespss- command has been written before Stata introduced support for unicode. So no wonder that it doesn't expect it in the content it processes.

        Admittedly, this should be mentioned in the list of the limitations at the homepage of -savespss- (which was written around the same time).

        4. Why doesn't Stata offer export to spss itself?

        That is probably a question to StataCorp.

        In any case, if *.sav is not working as an exchange format for you, try something regular, like *.csv or a tab-delimited format.

        Best, Sergiy Radyakin


        Comment


        • #19
          Originally posted by Bruce Weaver View Post
          Hendri wrote:
          Thanks for clarifying why giving clients .dta files is not an option!
          From one of my earlier reactions: "However, we promised the users to give them spss files, so we will have to do that."

          Comment


          • #20
            Originally posted by Sergiy Radyakin View Post

            1. Somehow savespss is broken,

            Kindly, demonstrate this with a transparent and reproducible example, such as a single do-file, which constructs the dataset using input/generate/etc statements that we can all understand and trace. Have a side-by-side comparison of what you are seeing in Stata and what you are getting in SPSS, as well as clearly present the syntax of the commands you've called (in both systems).

            2. random extra empty string variables are added to the file produced, like V25_0

            They are not random, and the theory behind them is rather complex, but pretty much anyone will see them in a very old version of SPSS, as they are being used for compatibility with older versions, but newer versions shouldn't display anything confusing (if you are using SPSS 16 or later that shouldn't bother you, for earlier versions, may need to look this up).

            3. And it doesn't support unicode.

            Chen Samulsion has mentioned immediately that the -savespss- command has been written before Stata introduced support for unicode. So no wonder that it doesn't expect it in the content it processes.

            Admittedly, this should be mentioned in the list of the limitations at the homepage of -savespss- (which was written around the same time).

            4. Why doesn't Stata offer export to spss itself?

            That is probably a question to StataCorp.

            In any case, if *.sav is not working as an exchange format for you, try something regular, like *.csv or a tab-delimited format.

            Best, Sergiy Radyakin

            Thanks for checking the post. I fully understand your request 1, but the data is derived from a lot of sources to finally have a .dta file which also contains personal information. Hence I won't be posting that here, and posting my dozens of .do files will also not help. I will try to produce a minimal reproducing example when I have time for that, which is not the coming month. I hoped this would be a known issue with a quick fix.

            Furthermore, I am using spss 27, not an old version. Maybe some old bug in spss reappeared?

            Comment


            • #21
              Originally posted by Hendri Adriaens View Post

              ... I will try to produce a minimal reproducing example when I have time for that, which is not the coming month...
              Sure, take your time.
              Once you have it, please do not hesitate to share your example.
              Best, Sergiy

              Comment


              • #22
                Originally posted by Sergiy Radyakin View Post

                Admittedly, this should be mentioned in the list of the limitations at the homepage of -savespss- (which was written around the same time).
                I have added the appropriate warning in the limitations section of the homepage of -savespss- .

                Comment


                • #23
                  Originally posted by Sergiy Radyakin View Post

                  Sure, take your time.
                  Once you have it, please do not hesitate to share your example.
                  Best, Sergiy
                  Ok, finally found time to create a minimal example:

                  Code:
                  clear
                  set obs 1
                  gen str700 x = "hello world"
                  savespss "test.sav"
                  The spss file will have x, V1_0 and V1_1. savespss seems to have trouble with converting longer strings (which are allowed in spss). Note again that I have version 17 of stata and 27 of spss.

                  Comment


                  • #24
                    Hello Hendri,

                    I have reproduced the problem which you've described with the minimal example code that you've shared. Thank you.

                    In my trials I varied the length (700) and observed the ghost variables appear in case where the length of the "long variable" changes from 503 (still correct) to 504 (already incorrect). Neither 503 nor 504 sounds like some specific limit of either of the systems (Stata or SPSS).

                    I will need more time to investigate what is going on exactly and how to fix it. For the moment, be careful with the long string content.
                    Save the original data in Stata in addition to the exported SPSS file so that you can have a backup in case -savespss- is having a critical problem.

                    Best, Sergiy


                    Comment


                    • #25
                      A quick way to safely reduce the length reserved for string variables without loosing information is to use in Stata compres. Maybe you are lucky and your data actually requires less than 504 characters per observation.​​​​​​​
                      ---------------------------------
                      Maarten L. Buis
                      University of Konstanz
                      Department of history and sociology
                      box 40
                      78457 Konstanz
                      Germany
                      http://www.maartenbuis.nl
                      ---------------------------------

                      Comment


                      • #26
                        When -savespss- saves data, it tries to be verbose about any transformations that it is doing. For example:


                        Click image for larger version

Name:	savespss.png
Views:	1
Size:	107.6 KB
ID:	1640805




                        Knowing that (afaik) SPSS doesn't accommodate strings longer than 32,767 characters, it will truncate longer strLs (which may be much longer in Stata). Hence max strL parameter is standard in -savespss-:


                        Code:
                        program define savespss
                        version 10.0
                        syntax [anything], [replace extmiss(string) codepage(integer 1252) strlmax(integer 32767)]

                        Correspondingly, one could recast all vars to strL, then convert with option strlmax(503).

                        I don't really like it, because it doesn't shed any light on the nature of the problem. I still feel much safer with strings under 255 chars long.

                        If you encounter any problem with a shorter string, do let me know.

                        Hope this helps, Sergiy Radyakin

                        Comment


                        • #27
                          Originally posted by Sergiy Radyakin View Post
                          Correspondingly, one could recast all vars to strL, then convert with option strlmax(503).

                          I don't really like it, because it doesn't shed any light on the nature of the problem. I still feel much safer with strings under 255 chars long.

                          If you encounter any problem with a shorter string, do let me know.

                          Hope this helps, Sergiy Radyakin
                          Thanks for looking at this an the suggestion. I tried:

                          Code:
                          clear
                          set obs 1
                          gen str770 x = 70 * "hello world"
                          recast strL x
                          savespss "test.sav", replace
                          and also with "strlmax(503)" option. The above still produces the ghost variables. And truncating the variable is not an option as it contains more than 503 characters in the real life dataset so that would mean loosing data. Both stata and spss allow for large strings, so I hope this can be fixed.

                          Comment

                          Working...
                          X