我想知道您是否可以帮助我将数据转换为纵向格式。我有如下数据集(20 个变量):
ptno E0sex calpcvd calcvdea calrxgp age.baseline age.year1 age.year2 age.year3 age.year4 age.year5 age.year6 Baseline year1 year2 year3 year4 year5 year6 duration1
10021001 1 0 0 1 81.3744 82.3744 83.3744 84.3744 85.3744 86.3744 87.3744 0.66 0.68 0.64 0.64 0.38 8 8 6.5
10021002 1 0 0 2 81.18822 82.18822 83.18822 84.18822 85.18822 86.18822 87.18822 0.64 9 9 9 9 9 9 0.989041096
10021003 1 0 0 1 80.32307 81.32307 82.32307 83.32307 84.32307 85.32307 86.32307 0.63 8 9 9 9 9 9 1.21369863
10021004 1 0 0 1 87.00343 88.00343 89.00343 90.00343 91.00343 92.00343 93.00343 0.72 8 9 9 9 9 9 1.347945205
10021005 1 0 0 2 82.42026 83.42026 84.42026 85.42026 86.42026 87.42026 88.42026 0.74 8 8 8 8 8 9 5.052054795
10021006 1 0 0 2 81.54962 82.54962 83.54962 84.54962 85.54962 86.54962 87.54962 0.59 8 8 8 8 9 9 4.208219178
我想重新安排这个,例如(年龄全部组合为“年龄”和基线,year1 ...组合为实用程序:
id obs E0sex calpcvd calcvdea calrxgp age utility duration
10021001 1 1 0 0 1 81.3744 0.66 6.5
10021001 2 1 0 0 1 82.3744 0.68 6.5
10021001 3 1 0 0 1 83.3744 0.64 6.5
10021001 4 1 0 0 1 84.3744 0.64 6.5
10021001 5 1 0 0 1 85.3744 0.38 6.5
10021001 6 1 0 0 1 86.3744 8 6.5
10021001 7 1 0 0 1 87.3744 8 6.5
10021002 1 1 0 0 2 81.18822 0.64 0.989041096
10021002 2 1 0 0 2 82.18822 9 0.989041096
10021002 3 1 0 0 2 83.18822 9 0.989041096
10021002 4 1 0 0 2 84.18822 9 0.989041096
10021002 5 1 0 0 2 85.18822 9 0.989041096
10021002 6 1 0 0 2 86.18822 9 0.989041096
10021002 7 1 0 0 2 87.18822 9 0.989041096
最好的方法是什么?