Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Reply: Setting default .do file template?
From
Maarten Buis <[email protected]>
To
[email protected]
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\template.do"- 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
*------------------------------ end program ----------------------------------
Hope this helps,
Maarten
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/