Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Simplifying multiple cases of the if command
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Simplifying multiple cases of the if command
Date
Fri, 16 Nov 2012 17:55:57 +0000
You can go
... if inlist(news, 1, 3, 5)
That is another way to do it. See also
SJ-6-4 dm0026 . . . . . . Stata tip 39: In a list or out? In a range or out?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q4/06 SJ 6(4):593--595 (no commands)
tip for use of inlist() and inrange()
http://www.stata-journal.com/article.html?article=dm0026
or
http://statadaily.wordpress.com/2011/10/20/functions-inlist/
Nick
On Fri, Nov 16, 2012 at 5:33 PM, [email protected]
<[email protected]> wrote:
> This might be a very easy question, but if I have a number of things
> that have to hold when generating a variable, is there a way to
> simplify the following?
>
> generate variable if news== 1 | news == 3 | news ==5
>
> to something like
> generate variable if news == 1 | 3 | 5? I tried this
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/