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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Using capture drop


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Using capture drop
Date   Mon, 27 May 2013 20:39:54 +0100

We can't see the example that is sparking this but usually there is no
mystery here.

The difference between

drop foo

and

capture drop foo

is that the first will fail if -foo- does not exist, stopping your
program or do-file. The second will just sail on by if -foo- does not
exist. In effect, you are saying

"I don't want -foo-; so if it doesn't exist, that's fine by me."

That is on a level with

"I don't want dirty dishes in my kitchen, so wash them up if there are any"

and you don't expect a message saying

"There are no dirty dishes in your kitchen. What now?"

Of course, you are living dangerously. If -foo- was valuable, you lost
it. it's as if you were saving a dessert for later but somebody threw
it out.
Nick
njcoxstata@gmail.com


On 27 May 2013 20:21, Michael Stewart <michaelstewartresearch@gmail.com> wrote:
> Hi,
> I am trying to find the utility of command capture drop .
> I see that is being used in foreach loop etc but cannot understand  the logic.
> Can anyone please let me know if there is a good explanation along
> with examples anywhere in the web .
>
> --
> Thank you ,
> Yours Sincerely,
> Mike.
> *
> *   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