Bookmark and Share

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: Seeing if the last observation equals previous observations from a


From   "Clyde Schechter" <[email protected]>
To   [email protected]
Subject   Re: st: Seeing if the last observation equals previous observations from a
Date   Sun, 25 Apr 2010 09:42:54 -0700

<>

Sorry about the previous post--I accidently hit Send before I finished

If all you need to know is whether any of the observations equals the
last, and you don't need to specifically identify them, then this will
also work (and it doesn't matter what type of variable X is):

capture assert X != X[_N] if _n < _N
local nothing_equal = (c(rc) == 0)

You can then use the nothing_equal local macro to condition subsequent code:

if `nothing_equal' {
     // WHATEVER HAPPENS IF NO EARLIER VALUES OF X MATCH LAST
}
else {
     // WHATEVER HAPPENS IF THERE IS AT LEAST ONE MATCH
}



Clyde Schechter, MA MD
Associate Professor of Family & Social Medicine
Albert Einstein College of Medicine, Bronx, NY, USA

Please note new e-mail address: [email protected]



Clyde Schechter, MA MD
Associate Professor of Family & Social Medicine

Please note new e-mail address: [email protected]

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index