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]

st: change directory (cd) to where data is


From   "Allan Reese (Cefas)" <[email protected]>
To   <[email protected]>
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index