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


From   "Allan Reese (Cefas)" <[email protected]>
To   <[email protected]>
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
directory.

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'"
  end
  



*
*   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