Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Possible to change the working directory automatically (for instances when work is done on different computers)?


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: Possible to change the working directory automatically (for instances when work is done on different computers)?
Date   Thu, 18 Jun 2009 11:33:57 +0800

...


Try this:


cap cd "C:\work path in here"
if _rc {
*HOME
global data "C:\home path name in here"
 }
else  {
*WORK
global data "C:\work path in here"
}


use "$data\data.dta", clear





______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul 
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
If you live to be one hundred, you've got it made.
Very few people die past that age - George Burns


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Anna
Reimondos
Sent: Thursday, 18 June 2009 11:25 AM
To: [email protected]
Subject: st: Possible to change the working directory automatically (for
instances when work is done on different computers)?

Hello,
I work from my office, but nearly everyday I take things home to do as
well using an external hard drive. The setup of the folders on the
external harddrive is exactly the same as on my work computer, but
obviously the full pathname is different.

Whenever I use STATA I usually open of the program, then open the
do-file I am working on. At the top of the do file, the first thing
that is written is a change directory command "cd *******\Project_1"
, and then there are commands to read in the data and so on.

At the moment I have two cd commands written on each do-file one under
each other. One refers to the work pathname, and one refers to the
home one.
 If I am at work I run only the work cd command, and if I am at home
the work one. This works reasonably well but it is annoying that I
can't ever run the whole do file because I first have to check that
the correct cd command is written. Also sometimes the external
harddrive goes in different usb slots, which messes up the pathname
system.

My question is: Is there any way to set the working directory to the
one where the do-file came from, without explicitly stating the
pathname ?
Does anyone else have a good system that works from them if they
frequently work on different computers?

Cheers
Anna
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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