So I think my question is best shown with a set of pictures.
This is what my current data looks like:
So what you will notice is that For months 1 and 13, my column "growth value" has data, and everything inbetween or after is empty.
What I would like is the that months 2-12 use the growth value corresponding to month 1,
and months 14-26 use the growth value corresponding to month 13, and so on.
So my final data should look like this:
What would be the best way of achieving this? In my mind, I have something like this planned:
If (growth value) is not empty, then (growth value + 1) = growth value
--> repeat 12 times until growth value + 11 is reached, and do it by id and month#.
I just wasn't sure how to code this. I would appreciate any help.
This is what my current data looks like:
id | date | month # | growth value |
1 | June 1975 | 1 | 12 |
2 | June 1975 | 1 | . |
3 | June 1975 | 1 | 11 |
1 | July 1975 | 2 | . |
2 | July 1975 | 2 | . |
3 | July 1975 | 2 | . |
1 | Aug 1975 | 3 | . |
2 | Aug 1975 | 3 | . |
3 | Aug 1975 | 3 | . |
... | ................. | ............ | ................... |
1 | May 1976 | 12 | . |
2 | May 1976 | 12 | . |
3 | May 1976 | 12 | . |
1 | June 1976 | 13 | 9 |
2 | June 1976 | 13 | 8 |
3 | June 1976 | 13 | 11 |
1 | July 1976 | 14 | . |
2 | July 1976 | 14 | . |
3 | July 1976 | 14 | . |
So what you will notice is that For months 1 and 13, my column "growth value" has data, and everything inbetween or after is empty.
What I would like is the that months 2-12 use the growth value corresponding to month 1,
and months 14-26 use the growth value corresponding to month 13, and so on.
So my final data should look like this:
id | date | month # | growth value |
1 | June 1975 | 1 | 12 |
2 | June 1975 | 1 | . |
3 | June 1975 | 1 | 11 |
1 | July 1975 | 2 | 12 |
2 | July 1975 | 2 | . |
3 | July 1975 | 2 | 11 |
1 | Aug 1975 | 3 | 12 |
2 | Aug 1975 | 3 | . |
3 | Aug 1975 | 3 | 11 |
... | ................. | ............ | ................... |
1 | May 1976 | 12 | 12 |
2 | May 1976 | 12 | . |
3 | May 1976 | 12 | 11 |
1 | June 1976 | 13 | 9 |
2 | June 1976 | 13 | 8 |
3 | June 1976 | 13 | 11 |
1 | July 1976 | 14 | 9 |
2 | July 1976 | 14 | 8 |
3 | July 1976 | 14 | 11 |
What would be the best way of achieving this? In my mind, I have something like this planned:
If (growth value) is not empty, then (growth value + 1) = growth value
--> repeat 12 times until growth value + 11 is reached, and do it by id and month#.
I just wasn't sure how to code this. I would appreciate any help.
Comment