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]
st: Dropping Program Saved as an ado-file
From 
 
"Christoph Engel" <[email protected]> 
To 
 
[email protected] 
Subject 
 
st: Dropping Program Saved as an ado-file 
Date 
 
Wed, 05 Sep 2012 00:44:23 +0200 
Dear readers of Stata list,
 
On the following programming problem, your help would be greatly appreciated. 
 
I am writing a program, which I wish to save as an ado-file. The program consists of two components: a maximum likelihood estimator, and the program calling the estimator. I need several auxiliary variables that are available in both components. I have found out that this works if I generate them as _x-variables, i.e. as variables with the variable name preceded by an underscore (assuming that users are very unlikely to have such variable names in their original datasets). 
 
I begin my program with
       
      capt drop program myprogram
 
and then use
 
     capt drop _x
     capt drop _y
     (... one line for each auxiliary variable)
 
If I call the program from a do-file, this works just fine. But once I save the program as an ado-file, to make it automatically available, the program is no longer dropped when it is executed for the second time. This creates a problem (only) if users break the execution of the program; otherwise I drop all auxiliary variables at the end of my program.
 
The best I could find on Statalist is this answer by Nick Winter
 
http://www.stata.com/statalist/archive/2004-12/msg00568.html
 
This helps to understand, but not to solve my problem. Currently, the best I have come up with is adding a note to the help file: if users break the program, they should use "discard" before they reexecute the program. Is there a way to put this directly into the program?
 
Many thanks for any help!
 
Christoph Engel
 
 
_________________________________________________________________ 
Prof. Dr. Christoph Engel 
Max-Planck-Institut zur 
Erforschung von Gemeinschaftsgütern 
Max Planck Institute for Research on Collective Goods 
Kurt-Schumacher-Strasse 10 
D 53113 Bonn 
Tel. +49/228/91416-10 
Fax +49/228/91416-11 
e-mail:[email protected] 
http://www.coll.mpg.de 
http://www.coll.mpg.de/engel.html 
http://ideas.repec.org/e/pen22.html 
http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=251559 
_________________________________________________________________ 
 
 
 
 
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/