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]

st: How to identify two consequtives values of a variable


From   "Pablo.CARVALLO" <[email protected]>
To   [email protected]
Subject   st: How to identify two consequtives values of a variable
Date   Fri, 22 Jul 2011 13:06:21 -0400

Hi Statalist,

I create a variable x which states a local max (1), a local min(-1),
and 0 in other case. If x==1, the following value may be 0 or -1, but
it cannot be 1 again. For example, an 'ideal' x may be:

x
--
0
0
1
0
0
0
0
-1
0
0
1
-1
0
0
0
1

But I have something like this:

x
--
0
0
1
0
0
0
0
1 ----> this value is wrong, because previous x different from 0 was 1.
0
0
-1
1
0
0
0
-1

I need a variable 'y' which tells me when x takes this wrong values:

x     y
---------
0     0
0     0
1     0
0     0
0     0
0     0
0     0
1     1 ---> y==1
0     0
0     0
-1    0
1     0
0     0
0     0
0     0
-1    0

Thanks a lot!

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