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]
Related Posts with Help needed to create a (potentially simple) variable
Program + ForeachHi there, I am a new user here in this forum, so this is my first thread. My question: I am trying…
Saving svy: tab results to Excel with putexcelHi Statalisters, I’m trying to pull cross-tabulated percentages (estimated with svy: tab) out of St…
Minimum Detectable Effect Using Non-parametric Power Simulations on Existing Data and AssignmentI am interested in calculating the minimum detectable effect (MDE) using non-parametric power simula…
Randomized Inference for Panel Data-ritest- is a easy way to do Randomized Inference (thanks Simon HeB), but I'm not certain it works t…
Splitting string in two numeric variablesHello! My data set includes a variable called price that is recorded as an interval (in most cases):…
Subscribe to:
Post Comments (Atom)
0 Response to Help needed to create a (potentially simple) variable
Post a Comment