Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: how to avoid absolute path names in do-files?


From   Ernest Berkhout <Ernest.Berkhout@seo.nl>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how to avoid absolute path names in do-files?
Date   Tue, 22 Mar 2005 13:51:56 +0100

At 13:37 22/03/2005, you wrote:
Dear statalisters!

I have a question on how to organise my Stata files in such a way that I
can change the directory structure, or copy everything to a new place,
while double-clicking a do-file to run it still works. I am under
Windows XP, Stata 8.2.

Suppose a do-file in directory project dir\analysis\analysis1 contains
the lines

   capture log close
   log using "D:\project dir\analysis\analysis1\analysis1X.log", replace
   use "D:\project dir\data\data3\somedata.dta"

Now I want to be as flexible as possible and avoid absolute path names
at all. Since I have so many do-files (around 70), I am looking for a
solution where the path info is stored only in one place, and I use
references to this in my do-files, so that the above becomes

   log using "<analysis path>\analysis1\analysis1X.log", replace
   use "<data path>\data3\somedata.dta"
Do you really want to have absolute paths at all? If you are able to use only relative pathnames, there is no problem anymore. That means, if you're only using the directories 'project dir' and below, you can copy the whole directory tree without having to chance anything in your do-file.
Example: say you have D:\projectdir\dir1 & D:\projectdir\dir2.
If your do-file is in D:\projectdir\dir2 and you want to adress the directory "D:\projectdir" you could specify "../".
If your do-file is in D:\projectdir\dir2 and you want to adress the directory "D:\projectdir\dir1 you could specify "../dir1/"
etc. etc.

Is this of any help?


Ernest Berkhout
SEO Amsterdam Economics
University of Amsterdam
******************************************************
Room 3.08
Roetersstraat 29
1018 WB Amsterdam
The Netherlands

tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
http://www.seo.nl
===========================
A statistician: someone who insists
on being certain about uncertainty
===========================
*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index