Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Simplifying multiple cases of the if command


From   Richard Goldstein <richgold@ix.netcom.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Simplifying multiple cases of the if command
Date   Fri, 16 Nov 2012 12:52:33 -0500

look at the inlist function (-h inlist-)

Rich

On 11/16/12 12:33 PM, sanja_lutzeyer@ncsu.edu wrote:
> Hi all.
> 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
> 
> Thanks!
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index