capture program drop colhead program define colhead qui{ clear set obs 1 local i =1 gen str8 head="" local wd: word 1 of $colhead di "`wd'" while "`wd'"~="" { replace head="`wd'" in `i' local i=`i'+1 local wd: word `i' of $colhead di "`wd'" set obs `i' } drop in `i' qui gen byte n=_n qui gen byte i=1 reshape i i reshape j n reshape xij head qui reshape wide drop i l } end