[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: using pwd in an if statement
. capture cd Hannah
This will -cd- if possible and continue otherwise.
Christopher W. Ryan wrote:
If I am in a directory, say C:data\scholar\Hannah, and I type
I get an error message, as one might expect.
I am just learning to use .do files for the bulk of my analyses and data
manipulations, a la Svend Juul's great book. I usually try to -cd- to
the relevant project directory somewhere near the begining of a .do
file, then open the data file.
But if I am *already in* that directory when I run the .do file, Stata
gives the same sort of error:
unable to change to Hannah
end of do-file
Is there a way to cd on a conditional basis, such as "if I'm not already
in the Hannah directory, then change to it"? Would this require using
if c(pwd) !=
Since all of my project files are nested under a single directory for
research projects, I suppose I could always put in my do-files a -cd- to
that directory before the -cd- to the particular project directory.
* For searches and help try: