Hi,

I have the following type of wide panel data downloaded directly from Datastream. The stucture of the number of stocks "m" included in the sample and the number of variables with "n" will change:
Date; STOCK1 - VAR1 ; STOCK1 - VAR2 ; STOCK1 - VARn ; .... STOCK2 - VAR1 ; STOCK2 - VAR2 ; ... ; STOCK2 - VARn ; ...... ; STOCKm - VAR1 ; STOCKm - VARn

Here is an exemple:

Code:
 
Date AMAZON.COM - TOT RETURN IND AMAZON.COM - MARKET VALUE AMAZON.COM - DIVIDEND YIELD AMAZON.COM - PER AMAZON.COM - UNADJUSTED PRICE AMAZON.COM - BOOK VALUE PER SHARE AMAZON.COM - COMMON SHARES OUTSTANDING ABBOTT LABORATORIES - TOT RETURN IND ABBOTT LABORATORIES - MARKET VALUE ABBOTT LABORATORIES - DIVIDEND YIELD ABBOTT LABORATORIES - PER ABBOTT LABORATORIES - UNADJUSTED PRICE ABBOTT LABORATORIES - BOOK VALUE PER SHARE ABBOTT LABORATORIES - COMMON SHARES OUTSTANDING AES - TOT RETURN IND AES - MARKET VALUE
4/21/2017 45882.38 429475.1 0 183.4 898.53 57.25 484000 49507.01 75536.38 2.44 45.1 43.53 17.72 1743602 414.52 7502.99
5/21/2017 49013.11 458779.9 0 181.2 959.8401 57.25 484000 49086.21 74894.38 2.46 44.7 43.16 17.72 1743602 412.3 7393.61
6/21/2017 51177.7 479041.2 0 189.2 1002.23 57.25 484000 55239.05 84282.19 2.18 50.3 48.57 17.72 1743602 429.6 7703.88
7/21/2017 52374.63 492710.8 0 193.6 1025.67 57.25 484000 58137.11 88331.5 2.08 52.6 50.84 17.72 1743602 420.4 7538.84
8/21/2017 48678.64 457940.9 0 242.4 953.29 57.25 484000 55895.8 84926.13 2.17 68.3 48.88 17.72 1743602 417.83 7414.68
9/21/2017 49258.71 463398 0 245.3 964.6499 57.25 484000 58811.79 89356.63 2.06 71.8 51.43 17.72 1743602 414.11 7348.65
10/21/2017 50191.14 473636.9 0 250 982.9099 57.25 484000 64715.63 98030.63 1.88 44 56.32 17.72 1743602 414.11 7348.65
11/21/2017 58186.72 549088.5 0 290.1 1139.49 57.25 484000 64485.8 97682.5 1.89 43.8 56.12 17.72 1743602 399.97 7019.91
12/21/2017 59987.74 566084.1 0 299.1 1174.76 57.25 484000 65416.55 99092.38 1.97 44.4 56.93 17.72 1743602 399.6 7013.3
1/21/2018 66106.19 623822.1 0 329.6 1294.58 88.694 491000 68475 103235 1.89 46.3 59.31 17.386 1755619 442.12 7759.54
2/21/2018 75723.56 717891.8 0 325.8 1482.92 88.694 491000 68105.56 103016.3 1.9 53.3 58.99 17.386 1755619 389.25 6756.39
3/21/2018 80775.81 765789.4 0 347.5 1581.86 88.694 491000 72065.63 109006.2 1.79 56.4 62.42 17.386 1755619 410.94 7133.32
I would like to the data to be reshaped as follow:
Date; STOCK ; VAR1 ; VAR2 ; VARn

I include the data in a csv file if that can help.

Thanks a lot in advance!