I have a long table dataset with 6 columns (DAY YEAR serial var1 var2 var3). Column DAY repeated values [1, 2, 3, ...,365, 1, ...,365,....]. Column YEAR has the same value for every 365 rows [2010 repeat365 times, 2011 repeat 365 times,....].
I want it to be divided into every 365 rows (have the same value in column B), merge the new subsets horizontally. Another problem is the reshaped new wide-table will have repeatedly variables names, how can I reshape the table and rename variables to (DAY var1_2010 var2_2010 var4_2010 var1_2011 var2_2011 var3_2011 var1_2012...)? Thank you.