Codes for convering wide to long format