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]

st: Dropping Program Saved as an ado-file

From   "Christoph Engel" <>
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
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 


*   For searches and help try:

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