Announcement

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

  • restore and restore,preserve

    Hi,dear all
    The routine "preserve" is useful. However, I am not well understand the differences between
    preserve
    ...
    restore

    and

    preserve
    ...
    resotre,preserve

    Could anyone give me an example please? Thanks very much


    Bests,
    wanhaiyou

  • #2
    Run the do-file below, and you can see what the difference in behavior is.
    Code:
    version 13.1
    
    clear *
    set more off
    
    program define restore_only
        version 13.1
        syntax
    
        preserve
        // No op
        restore
        drop _all
    end
    
    program define restore_preserve
        version 13.1
        syntax
    
        preserve
        // No op
        restore, preserve
        drop _all
    end
    
    sysuse auto
    
    restore_preserve
    describe
    
    restore_only
    describe
    
    exit

    Comment


    • #3
      Thanks very much,Joseph Coveney.
      Yes, there exists the difference between two results. The data is empty after running the restore_only, but restore_preserve is not.
      However, I am still not well understand. Could you give me more detailed explaination on this issue please?

      Bests,
      wanhaiyou

      Comment


      • #4
        wanhaijou:
        -help preserve- will point you to the related entry in Stata 13.1 .pdf manual, where you can find the detailed explanation you need.

        Kind regards,
        Carlo
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks very much, Carlo Lazzaro.

          Bests,
          wanhaiyou

          Comment

          Working...
          X