[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: using pwd in an if statement
I think I see your point.
Currently, my usual approach is to start Stata, then use the File . . .
Do . . . drop-down menu to pick the do-file I want (which is indeed
already in the relevant project directory C:/data/scholar/hannah. So
this runs, say, gen_Hannah3.do, but absent a -cd- near the beginning of
gen_Hannah3.do, it leaves pwd as C:/data/scholar (what I have it set to
as the Stata default). It does not change it to C:/data/scholar/hannah.
It sounds like I should get more in the habit of using the command line,
change immediately to the directory of whatever project I am working on,
and then get used to using the -do- command.
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
and Wilson Family Practice Residency, Johnson City, NY
GnuPG and PGP public keys available at http://pgp.mit.edu
"If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea." [Antoine de St. Exupery]
Ulrich Kohler wrote:
So if I want to keep everything related to one project (command log,
output log, data) in that project's directory, then my
choices seem to be:
1. always use full path names
2. always -cd- to the proper directory at the beginning of a Stata
session (or the beginning of a do-file), using full path name or the
-fastce- package, and then can use relative (short) file names.
Do I have that right?
Almost, I think. I would not recommend to -cd /to/project/directory- at the
beginning of a do-file, as you have mentioned within the parentheses of your
second point. The do-files belonging to a specific project should be already
in the project directory, and you should start them from within that
directory. Hence in principal:
. cd /path/to/my/project/directory // <- -fastcd- makes this easier
. do mydo
where mydo.do contains only relative pathnames:
use xyz, clear //
capture mkdir logetc
capture mkdir graphs
log using logetc/mydo, replace
scatter y x, saving(graphs/mydo_1, replace)
graph export graphs/mydo_1.eps, replace
save mydo, replace
Other strategies might work as well. This one has survived changes from
Windows to Linux and Macintosh as well as relocations between Konstanz,
Mannheim, Los Angeles, Berlin and Washington.
* For searches and help try: