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, statalist.org 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   Rebecca Pope <rebecca.a.pope@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Reply: Setting default .do file template?
Date   Wed, 28 Nov 2012 09:32:57 -0600

Maarten,
Thanks for this. -doedit2- is nifty. This is why I love the list.

Out of curiosity, can you explain why you have -local file: list clean
file- in the program? I tracked it down in the manual & read that
-list clean- is an extended macro function to minimally adorn the
elements of, in this case, "file". I understand this to mean removing
all unnecessary quotation marks. For general programming edification,
what do you gain by doing this?

As a general note for everyone, if you are like me and in the habit of
typing your file names without the extensions, that doesn't seem to
work here. You must type e.g. mydofile.do at the "This file:" prompt.

Rebecca



         __o                __o
      _`\ <,_            _`\ <,_
     (_)/   (_)          (_)/   (_)
=========================


On Wed, Nov 28, 2012 at 4:48 AM, Maarten Buis <maartenlbuis@gmail.com> wrote:
>
> 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/
*
*   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/


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