Dear Statalists,
for every id in my dataset there are var1 to var7 that represent different values. Some of the values in var1 to var7 are missing.
Now I would like to "compress" each observation/each line, so that first the non-missing values occur and then the missing values.
For example, for id=1, 3 of the 7 values are missing: var1, var3 and var7. I would like to replace var1 by var 2, var2 by var4, var3 by var5 and var4 by var 6, so that the 3 missing values are "at the end"
Any ideas how to do this systematically for a large dataset?
for every id in my dataset there are var1 to var7 that represent different values. Some of the values in var1 to var7 are missing.
Now I would like to "compress" each observation/each line, so that first the non-missing values occur and then the missing values.
For example, for id=1, 3 of the 7 values are missing: var1, var3 and var7. I would like to replace var1 by var 2, var2 by var4, var3 by var5 and var4 by var 6, so that the 3 missing values are "at the end"
Any ideas how to do this systematically for a large dataset?
Code:
clear input byte(id var1 var2 var3 var4 var5 var6 var7) 1 . 15 . 17 18 19 . 2 25 26 . 30 . . 12 end
Comment