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, 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)" <>
To   <>
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'"

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index