Hi everyone,

My data looks like below:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str15 location str10 odate byte population
"a" "2019-10-11" 4
"a" "2019-10-12" 2
"a" "2019-10-13" 6
"a" "2019-10-14" 1
"a" "2019-10-15" 5
"a" "2019-10-18" 4
"a" "2019-10-19" 4
"b" "2019-10-11" 4
"b" "2019-10-12" 2
"b" "2019-10-13" 6
"b" "2019-10-14" 1
end

I want to generate a new variable where for each location on each day, I want to calculate the cumulative population. For instance, for location a on 2019-10-12, I want to have pop=2+4=6 and fo r2019-10-13, I want to have pop=2+6+4=12.

It would be great if you have any idea how to do this in stata.

Thanks a lot!