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
Interpretation of threshold resultDear Community, I am a user of Stata 15. I am trying to estimate the threshold effects of inflation…
Bootstrapping with SUESTHi everyone, I should use Stata to make a mediatior analysis. I used the SUEST and I should do the …
Rescale a variable between 0 and 1 within industryDear Stata Users, I have a continuous variable “spread1”. I want to rescale it within industry – “s…
create a matrixHi all, This might be a trivial question but whatever I have tried seems not working. (e.g. looping…
Double fixed effects Yes/No with estoutI need to declare two fixed effects at bottom of regression table, but second fixed effect (Time FE)…
Subscribe to:
Post Comments (Atom)
0 Response to Randomly select contents from one variable in list
Post a Comment