Nice
I use Windows batch files to execute various Stata do-files in a certain order. For example, when I do
StataMP-64 /e do myDoFile1.do
StataMP-64 /e do myDoFile2.do
Stata executes myDoFile1.do and nicely routes its output to myDoFile1.log, and then executes myDoFile2.do and routes its output to myDoFile2.log. By the way, both log files are in the same directory as the do-files.
Not nice
Now I want to pass an argument for each of these do-file. In particular, this argument is a directory path. For example,
StataMP-64 /e do myDoFile1.do "C:\MyDir"
StataMP-64 /e do myDoFile2.do "C:\MyDir"
Now Stata executes myDoFile1.do as expected, but saves its output to a file named MyDir.log. And it does the same to myDoFile2.do, overwriting the log for myDoFile1.do.
Questions:
- Is this the expected behavior?
- How to solve this, and have outputs routed to
myDoFile1.logandmyDoFile2.dorespectively, preferably without the need to explicitly starting to log in each do file?
Edit 1:
Just to add to this problem, I tested the case in which I need to pass 2 directory paths to my do-file, like so
StataMP-64 /e do myDoFile1.do "C:\MyDir1" "C:\MyDir2"
The output is now routed to a file named MyDir2.log. Strange.
Edit 2:
I reproduced the example in Roberto's answer below. Here's the screenshot to show that the problem is indeed occurring. I use both a Windows batch file and the Windows prompt (which Roberto used in answer below), and I reproduced the problem either way. I am using Stata 13 MP on Windows 7.
Edit 3:
I've also replicated this on Stata 12 SE, Windows 7.
