Question

I have a lot of scripts (.do files) in different folders, which are frequently moved around. I would like to have Stata detect where the script is, and use that as a pwd (working directory). I know people that have this functionality seemingly by default (the pwd is changed to the script location when the script is run), but we cannot figure out why I am not so lucky. It is a bit tedious always having a "cd" line at the top of my scripts, and having to change this line to reflect the current directory. I'm using Stata 12 with Windows 7 Professional.

Was it helpful?

Solution

It looks to me like something similar is answered in this question:

Paths to do-file in Stata

What it seems like you could do is keep an MS Excel file that somehow tracks the location of all your scripts, and then use that to generate a simple high-level do-file that calls all your programs (although this may not be how your scripts work). If your folder locations are changing I am not sure how you can completely avoid updating at least some lines of code when something gets moved around. This would at least centralize the necessary updates into one place.

OTHER TIPS

You can use Sublime text.

https://sublime.wbond.net/packages/Stata%20Enhanced

When you build the do file (or a selection) using sublime text, the filepath of the do file automatically becomes the current directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top