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 on April 23, and its replacement, is already up and running.

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

Re: st: Reply: Setting default .do file template?

From   Maarten Buis <>
Subject   Re: st: Reply: Setting default .do file template?
Date   Wed, 28 Nov 2012 11:48:41 +0100

On Wed, Nov 28, 2012 at 3:53 AM,   Andrew Lover wrote:
>  I am hoping to have the second of your
> options- when opening a new .do file, I'd like my general header
> information and pre-analysis commands to appear by default:
> ************************************************
> * Project:
> * Analyst:
> * Date:
> * This file:
> ************************************************
> version 12
> clear all
> macro drop _all
> Your suggestion of -doedit "filepath\"- will certainly
> work, but is there a way to change the default file?

Maybe something like the program below. Store the part between
*----------- begin program ----- and *------ end program ------ in a
file called doedit2.ado, and store it somewhere where Stata can find
it. A good place is returned by Stata if you type in Stata -personal-.
After that the new command -doedit2- is available. If you type
-doedit2- in Stata you will be asked to give the project name, analyst
name and file name, and it will create the file with the header you
requested and open it in the dofile editor.

*----------------------------- begin program ---------------------------------
*! version 1.0.0 MLB 28Nov2012
program define doedit2
	display "Project: "   _request(_project)
	display "Analyst: "   _request(_analyst)
	display "This file: " _request(_file)
	local file : list clean file
	file open dofile using `file', write
	file write dofile `"*********************************"' _n
	file write dofile `"* Project:   `project'"' _n
	file write dofile `"* Analyst:   `analyst'"' _n
	file write dofile `"* Date:      `c(current_date)' `c(current_time)'"' _n
	file write dofile `"* This file: `file'"' _n
	file write dofile `"*********************************"' _n
	file write dofile _n
	file write dofile "version 12" _n
	file write dofile "clear all" _n
	file write dofile "macro drop _all" _n
	file close dofile
	doedit `file'
*------------------------------ end program ----------------------------------

Hope this helps,

Maarten L. Buis
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index