Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[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–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index