Don't know why this never took off - I'm sure I publicized it years ago. For anyone who's interested, put this program in your local ado directory. It's used after opening a data file. I keep projects in separate directories and at the start of session use File/Recent files to load the data, then type <godir> to make that the working directory. Simples! If anyone can improve the code, please do.

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