 <p>This code is not very elegant, but it does the job.</p> <pre><code>clear input obs v2 v3 v4 v5 v6 1 . 3 . . 1 2 2 . . 4 5 3 . 7 . . . 4 1 . 1 . 4 end gen strL nonmiss="" foreach var of varlist v2-v6 { replace nonmiss=nonmiss+" "+"`var'" if !missing(`var') } list nonmiss </code></pre>