黃河泉 发表于 2017-6-12 17:23 
可以試試
想麻烦请教黄老师,怎么根据某指数的月度收益率算这一年这个季度收益率
就是一个代码为300的指数
第二列是月度收益率
第三列是年份
第四列是月份
最后一列是所属季度
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input int indexcd float idxrtn int year byte month float quarter
300 -.0451 2005 1 1
300 .0891 2005 2 1
300 -.094 2005 3 1
300 -.0104 2005 4 2
300 -.081993 2005 5 2
300 .026567 2005 6 2
300 .010777 2005 7 3
300 .044767 2005 8 3
300 -.011348 2005 9 3
300 -.044812 2005 10 4
300 -.002796 2005 11 4
300 .056785 2005 12 4
300 .093291 2006 1 1
300 .042997 2006 2 1
300 .007673 2006 3 1
300 .104854 2006 4 2
300 .164712 2006 5 2
300 .02088 2006 6 2
300 -.071473 2006 7 3
300 .034273 2006 8 3
300 .048241 2006 9 3
300 .043612 2006 10 4
300 .170635 2006 11 4
300 .190561 2006 12 4
300 .168683 2007 1 1
300 .066754 2007 2 1
300 .093222 2007 3 1
300 .279292 2007 4 2
300 .103757 2007 5 2
300 -.041719 2007 6 2
300 .185033 2007 7 3
300 .187476 2007 8 3
300 .053617 2007 9 3
300 .019304 2007 10 4
300 -.167201 2007 11 4
300 .126835 2007 12 4
300 -.134478 2008 1 1
300 .01172 2008 2 1
300 -.189113 2008 3 1
300 .044477 2008 4 2
300 -.087845 2008 5 2
--more--