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


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. 

+49 (030) 25491-361
*   For searches and help try:

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