Statalist


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

st: Re: Re: How can I check that a variable exists?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: How can I check that a variable exists?
Date   Thu, 12 Mar 2009 23:25:16 +0100

<>

"capture confirm weight" should be "capture confirm variable weight"


HTH
Martin
_______________________
----- Original Message ----- From: "Martin Weiss" <[email protected]>
To: <[email protected]>
Sent: Thursday, March 12, 2009 11:22 PM
Subject: st: Re: How can I check that a variable exists?


<>

******
sysuse auto, clear

capture confirm variable weight
if !_rc {
                       di in red "weight exists"
               }
               else {
                       di in red "weight does not exist"
               }


drop weight

capture confirm weight
if !_rc {
                       di in red "weight exists"
               }
               else {
                       di in red "weight does not exist"
               }
******

HTH
Martin
_______________________
----- Original Message ----- From: "Benjamin Villena Roldan" <[email protected]>
To: <[email protected]>
Sent: Thursday, March 12, 2009 11:16 PM
Subject: st: How can I check that a variable exists?


Dear statalist,
This may sound like a trivial question, but I unsuccessfully looked for an
answer so far.
 I need to perform certain action A if there is a variable XA defined in
the dta file, and an action B if there is a variable XB in the dta file. How
can I do so? Any ideas?

Thanks

Benjamin


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index