Dear Everybody

I'm trying to run a SUR regression and need to reshape my data accordingly. The data contains ID, wave (1 to 4), four dependent variables (Y1-Y4) and fifteen independent variables (x1-x15).
I'm trying to get the dependent variables in one column and then create a diagonal matrix for each of the independent variables, with the other three rows filled with 0s.

Structure of the data now (example with 4 observations):
ID wave Y1 Y2 Y3 Y4 X1 X2 X3 ...
1 1 0.2 0.1 -0.5 1 1 1
1 2 2 0 0
2 1 0 0
2 4 1 -2 1 1 1

Structure I'm looking for:
ID wave Y X1_y1 X1_y2 X1_y3 X1_y4 X2_y1 X2_y2 X2_y3 X2_y4 X3_y1 X3_y2 ...
1 1 0.2 1 0 0 0 1 0 0 0 1 0 ...
1 2 2 0 0 0 0 0 0 0 0 ...
2 1 0 0 0 0 0 0 0 0 0 ...
2 4 1 0 0 0 1 0 0 0 1 0 ...
1 1 0 1 0 0 0 1 0 0 0 1 ...
1 2 0 0 0 0 0 0 0 0 0 ...
2 1 0 0 0 0 0 0 0 0 0 ...
2 4 1 0 1 0 0 0 1 0 0 0 1 ...
... ... ... ... ... ... ... ... ... ... ... ... ... ...

I created a variable identifying all observations uniquely in combining ID and wave and then tried to change the data structure with the reshape-command. But somehow it didn't work.
Can anyone help?


Thanks a lot!
Best,
Arto