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

Re: st: Is there an equivalent of ACCESS IIF function in STATA?


From   "Neil Shephard" <[email protected]>
To   [email protected]
Subject   Re: st: Is there an equivalent of ACCESS IIF function in STATA?
Date   Mon, 05 Jul 2004 22:15:55 +0000

> In ACCESS the IIF function returns one value if a specified condition
> evaluates to TRUE, or another value if it evaluates to FALSE:
> 
> IIF (condition, value_if_true, value_if_false)
> 
> condition is the value that you want to test.
> value_if_true is the value that is returned if condition evaluates to TRUE.
> value_if_false is the value that is return if condition evaluates to FALSE
> 
> I'm looking for a similar function in STATA in order to set a variable to
> two different values based on a condition test.
> 
> Is there such a function existing? Or, any other easy way to work this out?

There is indeed an analogous function called cond() (which actually has two formx)

cond(x,a,b)
cond(x,a,b,c)

Where x is the test,
a is true,
b is false,
and c if x evaluates to missing.

See man progfun and the others listed under man functions for more useful functions.

Neil

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm

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