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
how to deal with endogenous control variables when implementing ivreg2hDear STATALIST, I am using Stata/MP 14.0, and I am referring to a SSC function "ivreg2h". I am run…
How to find the significance level of marginal effects?Hello, there are so many topics about marginal effect using -margins- command. But most of them talk…
Wrong coefficient in a fixed effects panel regressionHello, I'm trying to regress the impact that fiscal rules might have on the Primary Balance of a Co…
Double selection lasso with interaction terms as vars of interestHello, I am currently using dsregress to estimate a double-selection lasso linear regression using …
Using variable measured at different levels in a regressionDear statalist, I am studying the effect of banking competition at the local level on the relations…
Subscribe to:
Post Comments (Atom)
0 Response to Randomly select contents from one variable in list
Post a Comment