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]

From |
"Christoph Engel" <engel@coll.mpg.de> |

To |
statalist@hsphsun2.harvard.edu |

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:engel@coll.mpg.de 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/

**Follow-Ups**:**Re: st: Dropping Program Saved as an ado-file***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: Dropping Program Saved as an ado-file***From:*Phil Clayton <philclayton@internode.on.net>

- Prev by Date:
**st: st " "Dummy Endogenous Variables in a Simultaneous Equation System" Hekman 78 in Stata** - Next by Date:
**st: RE: st " "Dummy Endogenous Variables in a Simultaneous Equation System" Hekman 78 in Stata** - Previous by thread:
**st: Need to Determine an Intervention Effect using xtmixed** - Next by thread:
**Re: st: Dropping Program Saved as an ado-file** - Index(es):