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

st: Re: Cross-platform mobility


From   ariley@stata.com (Alan Riley)
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: Cross-platform mobility
Date   Mon, 22 Sep 2003 15:13:06 -0500

Danielle H. Ferry (dferry@nber.org) asked about paths on a shared
Windows/Mac hard drive:
> Not sure if there is a solution to this, but I figured I'd throw it out
> there. I have an external hard drive which I use on both a Mac (OS X) and a
> PC (Win XP). I write all my Stata work to this HD. I sometimes call datasets
> or do-files from directories other than the one in which I am working. In
> this case, it is necessary to list the full pathname. The problem is that
> the pathname is specified with ":" as separators (i.e.,
> :hd:bigdirectory:smallerdirectory:filename.do) on a Mac but with "\" on a PC
> (i.e., C:\bigdirectory\smallerdirectory\filename.do). Notice also, that a
> Mac indicates the hard drive name by putting a ":" in front of the pathname
> and a PC specifies the hard drive name by putting a ":\" after the hard
> drive name. Much thanks for any ideas!

I have a couple of suggestions which may help.

First, start using "/" as the directory separator when working in Stata
on either platform.  Under Windows, Stata will understand

   e:/bigdirectory/smallerdirectory/filename.do

and under OS X, Stata will understand

   /hd/bigdirectory/smallerdirectory/filename.do

My second suggestion would be to create a macro containing the
operating system-specific portion of the path to the beginning
of the hard drive.  For example, in your profile.do for Stata for
Windows, you might put

   global HD "e:/"

and in your profile.do for Stata for Macintosh you might put

   global HD "/hd"

Then, you can work interactively on either platform or write do-files
on either platform which will work no matter whether you are using
the external drive with Windows or OS X.  This will work in either case:

   do $HD/bigdirectory/smallerdirectory/filename.do


--Alan
(ariley@stata.com)
*
*   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–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index