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, statalist.org is already up and running.


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

Re: st: RE: capture drop issue


From   A Loumiotis <antonis.loumiotis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: capture drop issue
Date   Wed, 7 Jul 2010 11:03:44 +0300

Thanks a lot Martin!

On Wed, Jul 7, 2010 at 10:53 AM, Martin Weiss <martin.weiss1@gmx.de> wrote:
>
> <>
>
> *************
> clear
> set obs 10
> gen obs=_n
> gen obs2=2*obs
> gen var1=runiform()
> gen var2=rnormal()
> gen var3=var1*var2
> list
> drop obs2
>
> loc mydropvars obs2 var1-var3
> foreach var of local mydropvars{
>        capture drop `var'
>        di in r "return code for: `var': " _rc
> }
> list
> *************
>
>
> HTH
> Martin
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of A Loumiotis
> Sent: Mittwoch, 7. Juli 2010 09:43
> To: statalist@hsphsun2.harvard.edu
> Subject: st: capture drop issue
>
> Hi,
>
> I face the following problem with capture drop varlist.
> If one of the variables in the varlist does not exist,  capture drop
> does not drop the rest of the variables in the varlist.
> I use Stata 11.
>
> Here is an example:
>
> ******
> clear
> set obs 10
> gen obs=_n
> gen obs2=2*obs
> gen var1=runiform()
> gen var2=rnormal()
> gen var3=var1*var2
> list
> drop obs2
> capture drop obs2 var1-var3
> list
> *****
>
> I would like my capture drop call to drop var1-var3 but because obs2
> is already dropped for some reason capture drop does not drop
> var1-var3.
> Is there an easy fix?
> Thanks,
> Antonis Loumiotis
> *
> *   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/
>
> *
> *   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/
>

*
*   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/


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