Dear Statalist,

I know how to reshape long a dataset when it has the appropriate format, but I'm facing two unusual situations that require assistance. In both cases, I would like to have a dataset that looks like this:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str4 name str2 id
"xxxx" "K1"
"yyyy" "K2"
"zzzz" "K3"
"aaaa" "K4"
end
However, the two datasets I have in front of me have this format:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str4(DV DW DX DY) str2(FT FU FV FW)
"xxxx" "yyyy" "zzzz" "aaaa" "K1" "K2" "K3" "K4"
end
i.e. the name variable and the id variable are in one line. Here is the second dataset :

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str4(DV DW DX DY)
"xxxx" "yyyy" "zzzz" "aaaa"
"K1"   "K2"   "K3"   "K4"  
end
Could someone help me finding how to reach the first example from the two last examples I provided? Thank you so much!