Announcement

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

  • saveold behavior.

    Dear All,

    can someone run the following in Stata 18 and tell me what the exact error message is, please?

    Code:
    clear all
    sysuse auto
    tempfile tmp
    saveold `"`tmp'"', version(5)
    PS: I know I can't save to version 5. But I need to know what is the lowest supported version that one can specify to saveold command in version 18.

    In Stata 17 I am getting:

    Code:
    version(5) invalid
        Stata 17 can write .dta files for Stata 17, 16, 15, 14, 13, 12, or 11.  It cannot write .dta formats older than that.
        (Stata 11 was released in 2009.)
    r(198);

    And a couple of questions, perhaps to the Developers of Stata:

    1. Is there any reason why saveold doesn't support the emptyok option?
    2. I am getting the following messages in Stata 17:
    Code:
    . saveold `"`tmp'"', version(14)
    (Stata 17 saves in the same format as Stata 16, Stata 15, and Stata 14.  You could have used save instead of saveold.)
    file C:\Users\.......\AppData\Local\Temp\ST_2d28_000002.tmp saved as .dta format
    
    . dtaversion `"`tmp'"'
      (file "C:\Users\.......\AppData\Local\Temp\ST_2d28_000002.tmp" is .dta-format 119 from Stata 15, 16, or 17)
    Is there any reason Stata 14 is mentioned in the first message, but not in the second?

    Thank you, Sergiy Radyakin

  • #2
    Code:
    version(5) invalid
        Stata 18 can write .dta files for Stata 18, 17, 16, 15, 14, 13, 12, or 11.  It cannot write .dta formats
        older than that.  (Stata 11 was released in 2009.)

    Comment


    • #3
      Dear Hemanshu Kumar, thank you very much for providing the Stata-18 output! Best, Sergiy

      Comment


      • #4
        Some thoughts:


        Originally posted by Sergiy Radyakin View Post
        I need to know what is the lowest supported version that one can specify to saveold command in version 18.
        There is no reason to expect the lowest supported version to change in the future for at least two reasons:

        1. Such a change would break old code
        2. Why would StataCorp invest time to rewrite saveold to not do what it already does? The costs of maintaining old code should approach zero here because old dta formats do not change.


        Originally posted by Sergiy Radyakin View Post
        1. Is there any reason why saveold doesn't support the emptyok option?
        The emptyok option has been around at least since Stata 11. From this perspective, there is no reason why it should not be allowed with saveold. If you wanted this badly, you could call save directly

        Code:
        save "`tmp'" , emptyok dtaformat(118)
        Option dtaformat() is non-documented, which is one reason not to use it. Another is that trying to save a dataset with 32,767 variables or less in format 119 will result in one of those errors you are not supposed to see r(9001).


        Originally posted by Sergiy Radyakin View Post
        2. I am getting the following messages in Stata 17:
        Code:
        . saveold `"`tmp'"', version(14)
        (Stata 17 saves in the same format as Stata 16, Stata 15, and Stata 14. You could have used save instead of saveold.)
        file C:\Users\.......\AppData\Local\Temp\ST_2d28_000002.tmp saved as .dta format
        
        . dtaversion `"`tmp'"'
        (file "C:\Users\.......\AppData\Local\Temp\ST_2d28_000002.tmp" is .dta-format 119 from Stata 15, 16, or 17)
        Is there any reason Stata 14 is mentioned in the first message, but not in the second?
        This probably points to a bug. I cannot test it because I do not have access to Stata MP. It is a bit complicated. I try to explain.

        As far as I know, the 119 format was introduced in Stata 15. When you specify version(14) in saveold in Stata 17, Stata 17 simply calls save. If you have more than 32,767 variables, save automatically writes format 119. Whether you can really open this in Stata 14, I do not know.

        It gets more interesting in Stata 18. Specifying version(14) with saveold should call save with (non-documented) option dtaformat(118). For datasets with more than 32,767 variables that should either lead to a corrupted dta-file or, more likely, to an error message in the 9000s. As stated, I cannot test this because I cannot create (or open) datasets with more than 32,767 variables.
        Last edited by daniel klein; 13 Jun 2023, 02:07.

        Comment


        • #5
          daniel klein

          when I run

          Code:
          clear all
          set maxvar 65000
          set obs 1
          forval i = 1/60000 {
              gen byte x_`i' = 1
          }
          
          saveold trial.dta, replace version(14)
          The last command gives the error:
          Code:
          (Stata 18 saves in the same format as Stata 17, Stata 16, Stata 15, and Stata 14.  You could have used save
            instead of saveold.)
          (file trial.dta not found)
          too many variables
              Data in memory contain 60,000 variables.  The old-format Stata dataset does not allow more than 32,767
              variables.
          r(459);

          Comment


          • #6
            Originally posted by Hemanshu Kumar View Post

            [...]

            The last command gives the error:
            Code:
            (Stata 18 saves in the same format as Stata 17, Stata 16, Stata 15, and Stata 14. You could have used save
            instead of saveold.)
            (file trial.dta not found)
            too many variables
            Data in memory contain 60,000 variables. The old-format Stata dataset does not allow more than 32,767
            variables.
            r(459);
            Thanks for running this.

            If this is intended behavior, i.e., if Stata 14 cannot read format 119 and, therefore, Stata 18 should not be able to save such a dataset in version(14), then the first message should arguably not appear in Stata 18. However, the error message is informative. I would call this at most a minor bug.

            In Stata 17, however, this code would produce a dataset that cannot be opened in Stata 14 without ever notifying the user about it. I guess this is a bug in Stata 17, then.
            Last edited by daniel klein; 13 Jun 2023, 04:01.

            Comment

            Working...
            X