Announcement

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

  • dataset in memory has changed since last saved

    Dear All, I am having difficulty understanding Stata's position in the following sequence of commands:

    Code:
    . tempfile tmp
    
    . save `"`tmp'"'
    file C:\Temp\ST_315c_000001.tmp saved
    
    . 
    . import delimited using "c:\data\input.csv"
    no; dataset in memory has changed since last saved
    r(4);
    How can the dataset in memory change since the last save if the save command was immediately preceding it? Is this some sort of AI feature to determine that saving to tempfiles is not the same as really saving it?

    I don't mind adding a clear statement in between, just trying to understand.

    PS: If it matters, commands are part of a do-file executed in Stata 16.0 on a Windows platform

    Thank you, Sergiy

  • #2
    How can the dataset in memory change since the last save if the save command was immediately preceding it?
    Reference is to the original dataset loaded. Notice that you can do the following:

    Code:
    sysuse auto, clear
    drop make
    tempfile auto2
    save `auto2'
    save auto
    Res.:

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . drop make
    
    . tempfile auto2
    
    . save `auto2'
    file C:\Users\709554\AppData\Local\Temp\ST_30c0_000001.tmp saved
    
    . save auto
    file auto.dta saved

    Comment


    • #3
      I don't see the point of two saves. If I could overwrite the original file I would, and then the tempfile is not needed.

      Stata knows whether the current dataset has changed by maintaining the system flag c(changed). The save command clears this flag, whether the dataset is saved with:
      • original file name;
      • different file name;
      • temporary file name.
      Hence my original question - NOTHING was run after the command save and before the command that failed with the data changed message.

      Instead my suspicion is that it is a bug and the message is incorrect and is a legacy of the insheet behavior which required that the memory must be cleared before importing new data, regardless of whether it is saved or not.
      To ensure that you do not lose something important, insheet will refuse to read new data if data are already in memory
      I didn't come across a similar note for the import delimited command.

      Comment


      • #4
        Yes, I hadn't tried your code using import delimited. It appears that the command will not execute with data in memory. If this behavior is maintained, the error code should revert to that of insheet.


        Code:
        . insheet "C:\Users\709554\Documents\myfile.csv"
        you must start with an empty dataset
        r(18);

        Comment

        Working...
        X