Statalist The Stata Listserver


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

st: Function that writes the location of the current do-file ?


From   "Sergio Correia" <[email protected]>
To   [email protected]
Subject   st: Function that writes the location of the current do-file ?
Date   Thu, 1 Jun 2006 15:57:04 -0500

Dear all,

Usually, when writing a do file, the first lines are like this:

clear
set mem..
set more off..
cd c:/project/data  // !!!!!!

The problem is that, when using the do files on different computers,
or giving the data + do-files to a colleague, they have to change each
do-file to match the location of the data (ie, change cd
c:/project/data to cd "c:/my documents/john/reviews/data")

My question is, is there a way to do something like

cd `currentdofile'

Where `currentdofile' gives the path to the do file currently running.

Assuming that the do files are in a folder like c:/project/prg , then I can
cd ..
cd data

And I don't longer have to update locations if the path changes.

I'm aware that other languages do this, but i don't know if there is
any way to do this in Stata.

Thanks,

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