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   Eva Poen <eva.poen@unisg.ch>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how to avoid absolute path names in do-files?
Date   Tue, 22 Mar 2005 17:48:51 +0100

Thanks a lot to all who replied. The fastcd package is a very nice
utility! I added it to my list of favourite commands.
For my current project I will try the solution with a profile.do in my
personal ado-directory, as Jean, Michael and Christian suggested.

Best,
Eva


Nick Winter wrote on 22.03.2005 15:44:
> My fastcd package (available from SSC) might help out here.  It includes
> a program called "c", that lets you define a series of shortcut names
> and associated directories, and then change to the associated directory
> by invoking the shortcut.
> 
> In my .do files, I often begin with a command like
> 
>   . c apsa05
> 
> which changes to the directory for the "apsa05" project.  The nice thing
> is that if the apsa05 project is moved at a later date, all I need to do
> is update the database of shortcuts, and the .do file will still work
> appropriately.
> 
> --Nick Winter
> 
> 
> At 01:37 PM 3/22/2005 +0100, 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"
>>
>> Preferably, the path info is stored somewhere in the project directory
>> itself, under the top level directory. If I decided to have "project
>> dir\old version\data\..." in a few months, I'd just have to change
>> "project dir\pathinfo" to adjust the paths.
>>
>> I know about global variables, but my problem is that I don't know how
>> to define them from within the project directory, such that
>> double-clicking a do-file works.
>>
>> Any ideas on how to accomplish this?
>>
>> Thanks a lot,
>> Eva Poen
>>
>> *
>> *   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/
> 
> 
> --------------------------------------------------------
> Nicholas Winter                           607.255.8819 t
> Assistant Professor                       607.255.4530 f
> Department of Government              nw53@cornell.edu e
> 308 White Hall            falcon.arts.cornell.edu/nw53 w
> Cornell University
> Ithaca, NY 14853-4601
> 
> *
> *   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/
> 


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