Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: auto macro for name of do file?

From   Phil Schumm <>
Subject   Re: st: auto macro for name of do file?
Date   Wed, 25 May 2011 11:44:17 -0500

On May 25, 2011, at 11:02 AM, Paul Burkander wrote:
Sorry, I must have missed that in your previous email.


I'm working with a team on a large data cleaning project. Right now I'm writing an ado file that uses stata's merge command, but produces a series of reports with each merge. I wanted the name of the reports to use the name of the do file. There are many people working on the project, with varying experience with Stata, so I'm trying to make this process as user friendly as possible.

Ok, that helps. From what you've said, I would suggest one of the following:

1) In your program (i.e., ado-file), add a "do-file name" parameter (possibly required). Then in your do-file, call the program like this:

loc fname <name of do-file>

<do-file code>

myprogram <merge spec> <varlist> <using filename>, <options> dofile(`"`fname'"')

2) Alternatively, you could set up the report (complete with header including the do-file name) in the do-file itself, and then just capture the output of your command as part of the normal logging process. This might work well if you are using -log- to generate your report, but not if you are writing the report yourself (i.e., via - file write-).

Others may have better suggestions...

-- Phil

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index