Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: store variable names in local macro


From   Maarten buis <[email protected]>
To   [email protected]
Subject   RE: st: RE: store variable names in local macro
Date   Tue, 29 Jan 2008 21:30:55 +0000 (GMT)

-- Nick wrote:
> If the argument is not a variable in the dataset, the return code
> from -confirm- will be positive, and if it is, the return code will
be
> zero. So, 
> 
> !_rc 
> 
> is non-zero if it's present and zero otherwise. So Maarten's second
> example does not read quite correctly. 

The code is a bit cryptic, but it is correct. In my code !_rc should
return false if the the variable is absent. The ! negates the statement
following it: _rc. In Stata 0 is false and any positive number is true,
so if the variable is absent _rc will contain a positive number (true)
and ! negates it and turns it into false (0). If the variable is
present than _rc contains false (0) and ! negates it and turns it into
true. The way you can make sense of this code is to read -if !_rc- as
"if no problem".

*----------- begin example ------------
sysuse auto, clear
capture confirm variable price
if !_rc {
	di "price is pressent"
}
sysuse nlsw88, clear
capture confirm variable price
if !_rc {
	di "price is present"
}
*------------ end example -------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.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/



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