I have a database with 10,000 entries and I need to correct the dates. Each row is indexed by ID and Year. The time between events and the start date are correct but the dates are wrong. An example of my dataset is below:
ID Date Time First_Date Year
1 ooo-207 1982-05-09 0 1982-05-09 1982
2 ooo-207 1982-05-09 12 1982-05-09 1982
3 ooo-207 1982-06-02 12 1982-05-09 1982
4 ooo-207 1982-06-02 10 1982-05-09 1982
5 ooo-207 1982-06-02 12 1982-05-09 1982
6 ooo-208 1982-07-06 0 1982-07-06 1982
7 ooo-208 1982-07-07 10 1982-06-12 1982
8 ooo-208 1982-07-08 11 1982-06-12 1982
9 ooo-208 1982-08-09 11 1982-06-12 1982
I need to correct the dates by Time to First_Date in a staggered fashion. After each new date is computed, that new date becomes the starting point to add the next waiting time. I need to do this from each animal for each year. The new dataset would look like:
ID Date Time First_Date Year
1 ooo-207 1982-05-09 0 1982-05-09 1982
2 ooo-207 1982-05-21 12 1982-05-09 1982
3 ooo-207 1982-06-02 12 1982-05-09 1982
4 ooo-207 1982-06-12 10 1982-05-09 1982
5 ooo-207 1982-06-24 12 1982-05-09 1982
6 ooo-208 1982-07-06 0 1982-07-06 1982
7 ooo-208 1982-07-16 10 1982-07-06 1982
8 ooo-208 1982-07-27 11 1982-07-06 1982
9 ooo-208 1982-08-07 11 1982-07-06 1982