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
Reshape long Datastream equity dataHi, I have the following type of wide panel data downloaded directly from Datastream. The stucture …
How to add extra column to summary statistics with asdoc?Dear all, I am using the asdoc tool to export my tables to word. However, I am struggling to add an…
Exporting multiple tabs to Excel with putexcelHi! I got this code that allows me to export a simple tabulation of the variable "Edad" to Excel: t…
egen numeric variableDear Stata users, Please take a look at this problem: I wish to generate a unique identifier for a …
Tariff data to use in StataHello, I am new to this forum and econometrics in general so im not sure this is a appropriate line…
Subscribe to:
Post Comments (Atom)
0 Response to Randomly select contents from one variable in list
Post a Comment