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: Update to godir.ado (cd to data directory)

From   "Allan Reese (Cefas)" <>
To   <>
Subject   st: Update to godir.ado (cd to data directory)
Date   Tue, 3 Jul 2012 09:32:49 +0100

Thanks to Dan Blanchette, a much improved little program to change
directory to one from which you've just -use-d a dataset.  A suggestion
to StataCorp would be to add a -cd- option to -use-, so -use
"blah/thisdata, cd" would load the data and make blah the current

program godir
  version 8
  if strpos(reverse("$S_FN"),"/") {
     local lastslash = length("$S_FN")-strpos(reverse("$S_FN"),"/")
   else {
     local lastslash = length("$S_FN")-strpos(reverse("$S_FN"),"\")
  local target = substr("$S_FN", 1,`lastslash')
  if strpos("`target'", ".dta") local target= "`c(pwd)'"
  cd "`target'"

*   For searches and help try:

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