Dear Statalisters,

I am having a little issue with the -reshape long- command as I'm discovering it for the first time and I'm not quite sure of how it works exactly. To put it briefly, I ran a regression with an interaction term between my first variable (var1, 8 values) and my second variable (var2, 7 values) and I generated 8*7 = 56 coefficients named coef_`i'_`j', i being the value of var1 and j being the value of var2. Now, I'd like to reshape long my variables coef, that is, I'd like to have one variable coef in a way that its modalities align with the appropriate var1 variable and the appropriate var2 variable. Here's a data example, even if I cannot show you the full picture because of memory restrictions:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float var1 byte var2 float(coef_3_1 coef_4_5 coef_2_7)
1 5 .2391724 -.037122227 .021247435
1 6 .2391724 -.037122227 .021247435
1 5 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 8 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 9 .2391724 -.037122227 .021247435
1 9 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 5 .2391724 -.037122227 .021247435
1 5 .2391724 -.037122227 .021247435
1 3 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 9 .2391724 -.037122227 .021247435
1 8 .2391724 -.037122227 .021247435
1 5 .2391724 -.037122227 .021247435
1 9 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 1 .2391724 -.037122227 .021247435
1 5 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
1 5 .2391724 -.037122227 .021247435
1 2 .2391724 -.037122227 .021247435
1 7 .2391724 -.037122227 .021247435
end

Long story short, I'd like my data to look like this:
var1 var2 coef
1 1 coef_1_1
1 2 coef_1_2
1 3 coef_1_3
... ... ...
2 1 coef_2_1
... ... ...
4 1 coef_4_1
... ... ...
8 7 coef_8_7
If my coef variable had only one index, namely, coef_`i', I'd know how to do, but I can't seem to find the appopropriate code for a combination of two variables. Any help would be much appreciated!

Regards,

Hugo