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
Related Posts with Randomly select contents from one variable in list
forvalues loop with the use of local valuesI got stuck in using forvalues with local values. I have variable x as an integer 1-100. I would lik…
Code for ownership concentration - with foreach loops?Dear all, I am new to STATA and tried to calculate a measure that captures the ownership concentrat…
Using Mvmete for multiple outcomes and multiple treatments?Can anyone help with Mvmeta. I am trying to analyse some complex data looking at the effect of an s…
Encode command with conditionsHi, I have a question about the "encode" command. my data is as below. I need to use the "cluster" …
Reshape data to create a stacked horizontal bar-graph, such as catplot from ssc, for several variablesDear all, First of all, I am really sorry this post is so long winded. I was not sure how much info…
Subscribe to:
Post Comments (Atom)
0 Response to Randomly select contents from one variable in list
Post a Comment