Hi,

I need to create a variable that essentially sums the number of 1s each participant has accumulated so far. The variable I need to create is I2. On the left of the image is an example of some data but with the I2 column blank, on the right is the I2 column filled in with the correct values. In STATA, how would I create variable I2.

So for example, with participant 14973 at the first date they had a 0 in I1, therefore I2 = 0. At the next date, that participant had a 1 in I1, therefore I2 = 1. At the next date, that participant had a 0 in I1, therefore I2 = 1 (this is because I2 is a running total of how many 1's in I1 that the participant has accumulated so far). etc.

I would like to know how to create that variable in STATA, and I have so many participants that it will be impossible to do this individually for each person.

Please any help would be greatly appreciated!

Many thanks!

[ATTACH=CONFIG]temp_17774_1587212011051_342[/ATTACH]