[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: An ado file for quickly switching working directories

From   Nick Winter <>
Subject   Re: st: An ado file for quickly switching working directories
Date   Mon, 14 Jul 2008 13:57:13 -0400

This looks like something quite similar to my program -c-, contained in the package -fastcd- on SSC.

--Nick Winter

Malcolm Wardlaw wrote:

I have a lot of original data sequestered away in specific working directories that I like to be able to access on the fly when I am doing quick and dirty analysis on data (as opposed to more formal programming where I use do files).

I'm not an expert programmer and, while it works, I'm not sure if this is the most efficient way to go about it. It basically reads an existing text file line by line and takes the first matching variable cue to switch directories. It also provides for a reading of the entire list of potential directories with the variable "list". I'll post the file below. If anyone has any better approaches (or possible extensions), I'd like to hear them. Also, I don't know if there's already a better, pre-constructed file for this. If it's an OK approach, then I suppose I'd just like to share it with everyone if people would like to use it.

program define wd
version 9.2
if "`1'" == "list" {
type "c:\ado\personal\workingdir.txt"
di("<--current directory-->")
di("<--current directory-->")

tempname fh
local linenum = 0
file open `fh' using "c:\ado\personal\workingdir.txt", read
file read `fh' line
while r(eof)==0{
local a: word 2 of `line'
if word(`" `macval(line)'"',1)=="`1'"{
cd "`a'"
file read `fh' line
file close `fh'

data "c:\data"

ds "c:\my documents\dealscan original\"

dse "c:\my documents\Stata Data\fixed master\"

gold "c:\my documents\Stata Data\Gold data\"

cov "c:\My Documents\Stata Data\Covenant Research\"

ado "c:\ado\personal"

myd "c:\My Documents\Stata Data\"

* For searches and help try:
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics         e
University of Virginia w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index