Hi All,

I am essentially trying to compress a row of variables into just the non-missing entries. My dataset looks like this

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(q5__1 q5__2 q5__3 q5__4 q5__5 q5__6 q5__7 q5__8 q5__9 q5__10)
. 2 . . . . . . 0 0
1 . . . . . . . 0 0
. . . . . . . . 0 0
. . . . . . . . 0 0
. . . . . . . . 0 0
. . . . . . . . 0 0
. 2 . . . . . . 0 0
1 . . . . . . . 0 0
. . 3 . . . . . 0 0
. . . 4 . . . . 0 0
. . . . . . 7 . 0 0
end
So I was to gen var_a = the first non missing value from each column, so that would be all the observations basically, 2,1,.,.,.,.,2,1,3,4,7. If there are more, then the next variable var_b would include them, but would be missing otherwise.

Any ideas?

Many thanks!

Chris