Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73249

Is there a command like -egen rowrandom()-?

$
0
0
Hi all,

I have data set that look like this:

Code:
input str1 id x1 x2 x3 x4 x5
"A" 1 . 2 . 2
"B" 5 1 3 5 5
"C" 2 3 2 . 1
"D" . . . . .
"E" 6 6 1 4 1
end
Is there a command that creates a new variable x which contains a randomly chosen non-missing value of the variables x1 to x5. (And if all of x1 to x5 are missing (think D), x should also be missing.)

Is there a simple solution to this problem, think -egen x = rowrandom(x1 x2 x3 x4 x5)-?

Thanks
Go

Viewing all articles
Browse latest Browse all 73249

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>