Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Relative Paths in Stata 12


From   Robert Picard <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Relative Paths in Stata 12
Date   Fri, 6 Sep 2013 08:25:27 -0400

There's no voodoo in using relative paths. The only variable is the
location of Stata's current directory. Use -pwd- to display it. If you
do not explicitly set the current directory using -cd- or the
"File>Change Working Directory..." menu item, then relative paths may
or may not work. It just depends on the state of Stata at that time.
Bottom line, include a -cd- upstream if you plan to use relative
paths.

On Fri, Sep 6, 2013 at 1:39 AM, Conor Hughes <[email protected]> wrote:
> Robert, thanks for the tip with -project-, it seems to have a number
> of great features besides just relative paths. It should be very
> useful.
>
> While that should solve my issue, I am still a bit puzzled as to how
> relative paths end up working in some cases. I went back and re-ran
> the exact same code with relative paths on my other Mac running Stata
> 10, and had no problems. A team member running Stata 10 on a different
> Mac also had no problems with it. Additionally two colleagues I spoke
> with today said they'd successfully used them in the past, but gave up
> the practice after encountering similar issues to mine. Anyway, from a
> practical standpoint my question is answered. I am still curious about
> why it works in certain cases, though.
>
> Thanks again,
> Conor
>
> On Thu, Sep 5, 2013 at 2:36 PM, Robert Picard <[email protected]> wrote:
>> Relative paths are and have always been relative to the current
>> directory. One difference with Stata 12 is that on open, it restores
>> the current directory to what it was when the application quit. Before
>> that, Stata (Mac) opened with the user's home directory (~/documents/)
>> or the Stata application directory for version 9.
>>
>> Currently, there is no way to request from Stata the path to the
>> currently running do-file. In part, this is because the concept is
>> ambiguous as there can be more than one do-file running when do-files
>> are nested. You may want to take a look at -project-, recently added
>> to SSC. With -project-, the current directory is always aligned with
>> the currently running do-file so you can use relative paths as you
>> described.
>>
>>
>> On Thu, Sep 5, 2013 at 12:21 PM, Conor Hughes <[email protected]> wrote:
>>> Hello All,
>>> Recently I've been trying to  work on a project I originally began in
>>> Stata 10 on Mac OS. I'm now running Stata 12 (also on Mac), and
>>> finding that my relative paths aren't working as they were previously.
>>> For example, running a do file containing:
>>>
>>> clear all
>>> cap log close
>>> log using "./example.log", replace
>>>
>>> Previously, the "./" was evaluated as the directory of the do file
>>> that was running. Now when I try to run it, it just goes to the
>>> current working directory. The same happens when using "../", for
>>> example -insheet using "../import/raw.txt", clear-. Has anyone run
>>> into issues like this before? There will eventually be a number of
>>> people working on this out of a shared folder, so it would be
>>> preferable not to have to edit the working directory manually every
>>> time a new user goes to run something.
>>>
>>> Thanks, and have a great day,
>>> Conor
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index