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 at the end of May, and its replacement, statalist.org 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)" <allan.reese@cefas.co.uk>
To   <statalist@hsphsun2.harvard.edu>
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index