Dear Statalist users,
I am using panel data, have used txset and the date is in %td format.
I have several IDs and for each ID 365 days of data. I have a variable "T74" which contains only zero's or ones for each ID for each day.
I want to make a running sum of this variable "T74" over t until t+6 for each ID on each date.
So for the 7 days running sum I have tried the following:
However, it gives me the error:
, as I also need to make a running sum of 20 days I need a more clever way to code my problem.
Is there a nicer way to code my problem?
Thanks in advance,
Emilio
I am using panel data, have used txset and the date is in %td format.
I have several IDs and for each ID 365 days of data. I have a variable "T74" which contains only zero's or ones for each ID for each day.
I want to make a running sum of this variable "T74" over t until t+6 for each ID on each date.
So for the 7 days running sum I have tried the following:
Code:
gen Sum_T74 = sum(T74) + sum(f.T74) + sum(f2.T74) + sum(f3.T74) + sum(f4.T74) + sum(f5.T74) + sum(f6.T74) gen Run_SumT74 = s6.Sum_T74
too many sum() functions
Is there a nicer way to code my problem?
Thanks in advance,
Emilio
Comment