Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Make ado file end processing of calling do file

From   Phil Schumm <>
Subject   Re: st: Make ado file end processing of calling do file
Date   Mon, 23 May 2011 20:08:40 -0500

On May 23, 2011, at 7:02 PM, Paul Burkander wrote:
I'm new to writing ado files, and I'm having some trouble. I'd really like my ado file to stop the processing of the calling do file if certain conditions are met. I guess "exit" just returns control to the calling program.

Is there any way to make the calling program completely top based on a condition encountered in the ado file?

There are several ways to do what you want. For example, you could have your program exit with a specific return code, and then trap this in your do-file:

program define foo
    <program code ...>
    if <condition> {
        exit = <return code>

cap foo
if _rc == <return code> {

Alternatively, you could have your program set a global macro, and then check for specific values of this macro in your do-file following your call to the program. Though there are other ways, these are perhaps the best two.

The real question, however, is what are you trying to do? I'm guessing that there might be an alternative (and perhaps better) way to approach the problem...

-- Phil

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index