Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: change directory (cd) to where data is


From   "Allan Reese (Cefas)" <allan.reese@cefas.co.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: change directory (cd) to where data is
Date   Mon, 2 Jul 2012 14:03:22 +0100

This may be trivial and solved before; if so ignore.

Using the menu to retrieve a recently used dataset leaves you in the current directory.  Here's a trivial ado file to change into the directory of the current dataset.  May need adapting for Unix and Mac.  The name godir does not seem to be used elsewhere in Stata but is a stats website.

* Copy to c:\ado\personal\godir.ado
program godir
  local lastslash = length("$S_FN")-index(reverse("$S_FN"),"\")
  local target = substr("$S_FN", 1,`lastslash') 
  cd "`target'"
  end
  
Allan
  


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index