Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Keeping same ordered value from two ordered variables

    I have a wide-format data set where two sets of variables are x1, x2 and x3; and y1 y2 y3. I would like to find out minimum value of first set e.g min(x1, x2 and x3) and keep the corresponding y variable in the dataset. what would be stata command for doing such an operation.

  • #2
    What is your rule for ties? Suppose x1 x2 x3 are 1 1 2 and y1 y2 y3 are 42 666 3.14159. Do you choose 42 or 666?

    Consider some rule such as

    Code:
    cond(x1 == min(x1, x2, x3), y1, cond(x2 == min(x1, x2, x3), y2, y3))
    This wires in a preference for x1 deciding in cases of ties, then x2. If you want some other rule(s) you need to say what they are!
    Last edited by Nick Cox; 20 Aug 2018, 05:53.

    Comment

    Working...
    X