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: Generating a variable to indicate whether an array of variables is in increasing value


From   Mike <[email protected]>
To   [email protected]
Subject   st: Generating a variable to indicate whether an array of variables is in increasing value
Date   Wed, 1 Jun 2011 17:52:31 -1000

We have a data set, that have 4 variables: x1, x2, x3, x4. Can you
help generating a variable y whose value is constructed as follows:

y = 1  if x1>x2>x3>x4
y = 2  if x2>x1>x3>x4

and so on.

Sure, we can use something such as:

gen y=.
rep y =1 if x1>x2 &  x2>x3 & x3>x4

However, there is missing value in some of the x variables. Can you
suggest some efficient solution for this question?


-- 
"My father gave me the greatest gift anyone could give another person,
he believed in me." - Jim Valvano
*
*   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