Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: using pwd in an if statement


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: using pwd in an if statement
Date   Wed, 17 May 2006 09:07:12 +0200

> > 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
log close

exit
-------------------------

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. 

-- 
[email protected]
+49 (030) 25491-361
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index