Hello Statalisters - I know there is probably an easy way to do this, but for the life of me I cannot figure it out. I have a dataset that has daily air pollution values for a given person (in long form, though I could put it in wide form is that's easier, especially since I will ultimately need it in wide form) and I'm looking to create weekly values. Essentially, I would like to sum up the first 7 observations, the next 7, and so on. Below is an example dataset:
id day poll
1 1 5.840e-06
1 2 5.190e-06
1 3 3.700e-06
1 4 7.420e-06
1 5 4.150e-06
1 6 2.050e-06
1 7 .0000164
1 8 .0000515
1 9 .0000293
1 10 .0000206
1 11 .000016
1 12 .0000186
1 13 .000017
1 14 .0000118
1 15 9.340e-06
1 16 .0000187
1 17 .0000239
1 18 .0000227
1 19 .0000211
1 20 .0000184
1 21 .0000199
So, I would like the sum of days 1-7, 8-14, 15-21, etc. I have over a year's worth of daily values for most people, so manually putting in the specific days to sum over would be difficult.
Thanks!
id day poll
1 1 5.840e-06
1 2 5.190e-06
1 3 3.700e-06
1 4 7.420e-06
1 5 4.150e-06
1 6 2.050e-06
1 7 .0000164
1 8 .0000515
1 9 .0000293
1 10 .0000206
1 11 .000016
1 12 .0000186
1 13 .000017
1 14 .0000118
1 15 9.340e-06
1 16 .0000187
1 17 .0000239
1 18 .0000227
1 19 .0000211
1 20 .0000184
1 21 .0000199
So, I would like the sum of days 1-7, 8-14, 15-21, etc. I have over a year's worth of daily values for most people, so manually putting in the specific days to sum over would be difficult.
Thanks!
Comment