Hello,

For each observation, I have up to six variables that describe a potential location (x1-x6). x1 will always be filled, but any and all of x2-x6 could be missing.

I would like to randomly choose one of those non-missing variables (x1-x6) and create a new variable (z) that copies the content of that information over.

I would also like to know which variable x1-x6 was randomly chosen to fill z. That information could be input into a new variable (t).

Is there an elegant way to do this in Stata?

Thank you in advance for the help. I'm having a difficult time coming up with the right search terms to describe what I'm trying to accomplish!

All the best,
Megan