Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: problem with -capture drop-


From   "Jitian Sheu" <[email protected]>
To   <[email protected]>
Subject   st: Re: problem with -capture drop-
Date   Tue, 21 Oct 2003 16:29:46 -0400

this is because in this dataset, there is only one variable with the name
beginning from "r"
so, when you type: capture drop r
Stata refers the variable name, r, as the variable resid
So, that variable is dropped after you specify -capture drop r-




----- Original Message ----- 
From: "Eddy" <[email protected]>
To: <[email protected]>
Sent: Tuesday, October 21, 2003 4:15 PM
Subject: st: problem with -capture drop-


> Dear Statalisters,
>
> I encountered an odd behavior of -capture drop-, and would appreciate
> advice.
>
> I have a program in which a variable called "resid" was created
> first, and another variable "r" was created later. Before creating
> "r", I want to make sure that there is no existing variable sharing
> the same name. So I issue
>
>      capture drop r
>
> to make sure there is no "r" before it is created. The problem is,
> the above line also drops "resid" which I'd like to keep it there.
> The symptom can be illustrated as the follows.
>
> ---------- example -------------------
> . set obs 100
> obs was 0, now 100
>
> . gen resid = 1
>
> .
> . sum resid
>
>     Variable |       Obs        Mean    Std. Dev.       Min
> Max
> -------------+--------------------------------------------------------
>        resid |       100           1           0          1
> 1
>
> .
> . capture drop r
>
> .
> . sum resid
> no variables defined
> r(111);
>
> -------- end of example -------
>
> This is true for both Stata 7, 7SE, and 8SE. My question: Is this the
> intended behavior? Is there anyway to tell Stata to drop only those
> literally specified? Thanks.
>
> Eddy
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index