0
votes

I'm having difficulties to save the output of my regression. Stata is supposed to save the file as "output.dta" in the defined directory, however the file is not saved in this folder (and also nowhere else on my PC). Here is the final piece of code, where I want it to be saved:

if (`counter'==1) {
  save "C:\Users\Milla\Code\output", replace
  local counter = `counter' + 1
} 
if (`counter'!=1) {
cap append using "C:\Users\Milla\Code\output"
duplicates drop *, force
cap save "C:\Users\Milla\Code\output", replace
}

Does anyone have an idea why could this happen? The code runs well and throws no errors or warnings. But it also doesn't say "output.dta is saved" as it normally does, when one saves anything in Stata.

Thanks ahead and best regards, Milla

1
The reason the code throws no errors or warnings, and does not say "output.dta is saved" (for the save within the loop), is because you have used capture to suppress all the output from your append and save commands within the loop. Try removing the cap from these commands and rerunning and see what Stata tells you. - user4690969
What is the initial value of counter? You say that output.dta doesn't exist anywhere on the computer, so if counter != 1 when you run this, it will try to append using a non-existent file and throw an r(601) file not found error. You precede the append with capture, so any errors will be suppressed.Although I suppose it should still save the file on the second save command. - ander2ed

1 Answers

0
votes

try

 save "C:\Users\Milla\Code\output.dta", r