Dear All, I find this question here (in Chinese). The data set is:
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(A B C)
0 0  0
1 2  2
0 4  6
0 5 11
0 3 14
2 0  0
0 0  0
0 0  0
1 3  3
0 6  9
0 7 16
2 0  0
end
A and B are the raw data, and C is the desired result. The purpose is to calculate the cumulative sum of B, starting from A=1 to A=2 for each segment. Any suggestions are highly appreciated.