Announcement

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

  • Stata 17 - Question about Use command

    Hi,

    I have a sequence of code below...

    use "C:\Users\paulf\OneDrive\Stata Data\15-Just Start Here (Raw Data 2013 to Date).dta", clear
    gen ddate = daily(date, "DMY")
    format ddate %td
    egen horseid_nc = concat(horse_nc date)
    replace horseid_nc = lower(horseid_nc)
    save "C:\Users\paulf\OneDrive\Stata Data\15-Just Start Here (Raw Data 2013 to Date).dta", replace

    I have a different .dta open.
    I run the .do file
    The .do file reaches the code sequence above, then physically opens the .dta referenced in it, over the .dta I actually want open (so I lose that)

    My understanding is that whilst 'use' loads the .dta file it references into memory, the .dta remains in the background and does not physically open.
    Obviously that is not the case here though.

    I have looked in Preferences in the edit menu and found nothing there (Stata 17).

    Any information appreciated please. I would like it to remain in the background!

    Thank you.

  • #2
    The clear option means: drop all data in the current frame and replace it with the file specified in use. So your code is behaving as expected (but not as you want it).

    What you are looking for is frames, see help frames.You can have multiple datasets open at the same time. In that case you put them in different frames.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thanks, Maarten.

      With your steer I was able to find a solution.

      frame create temp
      frame change temp
      use "C:\Users\paulf\OneDrive\Stata Data\15-Just Start Here (Raw Data 2013 to Date).dta", clear
      gen ddate = daily(date, "DMY")
      format ddate %td
      egen horseid_nc = concat(horse_nc date)
      replace horseid_nc = lower(horseid_nc)
      save "C:\Users\paulf\OneDrive\Stata Data\15-Just Start Here (Raw Data 2013 to Date).dta", replace
      frame change default
      frame drop temp

      Comment

      Working...
      X