I am trying to generate a cumulative sum in Stata.
The data looks as follows:
id_marca wdate quantity indi cumquant
A.FAMILY 2986 0 0 1371
A.FAMILY 2987 33 4 1404
A.FAMILY 2988 128 0 1532
A.FAMILY 2989 74 1 1606
A.FAMILY 2990 157 4 1763
A.FAMILY 2991 317 9 2080
A.FAMILY 2992 414 2 2494
A.FAMILY 2993 305 1 2799
A.FAMILY 2994 225 0 3024
A.FAMILY 2995 226 1 3250
A.FAMILY 2996 188 1 3438
I want the cumulative sum to restart after the indicator variable "indi" is unequal to zero. This should be done for each id_marca (shown only one).
I would appreciate the help!
The data looks as follows:
id_marca wdate quantity indi cumquant
A.FAMILY 2986 0 0 1371
A.FAMILY 2987 33 4 1404
A.FAMILY 2988 128 0 1532
A.FAMILY 2989 74 1 1606
A.FAMILY 2990 157 4 1763
A.FAMILY 2991 317 9 2080
A.FAMILY 2992 414 2 2494
A.FAMILY 2993 305 1 2799
A.FAMILY 2994 225 0 3024
A.FAMILY 2995 226 1 3250
A.FAMILY 2996 188 1 3438
I want the cumulative sum to restart after the indicator variable "indi" is unequal to zero. This should be done for each id_marca (shown only one).
I would appreciate the help!
Comment