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 at the end of May, and its replacement, statalist.org is already up and running.


[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 <quangn@hawaii.edu>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index