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

Re: st: do file script from text wrangler

From   Steven Samuels <>
Subject   Re: st: do file script from text wrangler
Date   Thu, 2 Oct 2008 19:39:49 -0400

Nirali, I think now that I understand your problem. Your data is not in the same directory as your do-files. Now that you are starting Stata from your do-files with the dataninja script, Stata doesn't know where the data are. The solution is easy: in the do-files (not the script) tell Stata where to find the data.

Here is the method I use. I create local macros to make it easy to refer to the data sets. Suppose your data are in two different folders, data_1 and data_2 inside a "project" folder. Create the following macros:

local dat1 "~/Documents/Curr_Proj/project/data_1/" //path to data_1
local dat2 "~/Documents/Curr_Proj/project/data_2/" //not used here, but handy if you need it

use `dat1'd1_01, clear // use a data file in data_1
(some commands)
save `dat1'd1_02, replace // save the changes in another file (never the same one!)

Another possibility is to change the directory to your

To find the path to the do-files in BBEdit, I click the blue "i" button at the top of the document; one of the options is to copy the path to the clipboard. I'm sure that you can do the same in Text Wrangler. Tip: keep both the do-file and log folder and the data folders open where you can see them.

Good luck!


On Oct 2, 2008, at 3:14 PM, Nirali Shah wrote:


I recently downloaded the stata scripts from Dataninja. One of these scripts allows you to send your do file straight to stata. However, it appears that it also automatically changes the path directory to the path directory of the do file. Since I keep my do files and data files in different folders, every time I try and run a do file from Text Wrangler, Stata tells me that the data files are not found.

Aside from inserting a change directory line into each of my do files, is there a way I can change the script? I don't know anything about scripting language - what would I have to look for or write?

Thank you,
Nirali Shah
PhD Candidate, International Health, Health Systems Division
Bloomberg School of Public Health
Johns Hopkins University

* For searches and help try:
*   For searches and help try:

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