I have 2 columns (month and percent_change). The month is which month the data is from and the percent_change is how much lower costs are for month X compared to month X+1. Ultimately I'm trying to adjust for a pseudo-inflation.
I have data as follows (X=month, Y=percent_change)
X Y
6 0
5 3
4 2
3 2
2 4
1 5
....
....
(X=6 means June, X=5 means May.....X=1 means January).
So for example, costs in May are 3% lower than costs in June. Costs in April are 2% lower than costs in May......Costs in January are 5% lower than costs in February.
What I want to do is to create a new column which would appear as follows:
X Y Z
6 0 0
5 3 3
4 2 5
3 2 7
2 4 11
1 5 16
....
....
So basically column Z is a cumulative change in percent relative to month 6 (June). So, costs in January are actually 16% lower than costs in June. Costs in February are actually 11% lower than costs in June.....
So, Z for month 6 simply equals Y6.
Z for month 5 = Y6 + Y5.
Z for month 4 = Y6 + Y5 + Y4.
.....
.....
Can someone help me do this in SAS? I'm not sure if I need some type of DO LOOP or not? Hopefully this makes sense.
I have data as follows (X=month, Y=percent_change)
X Y
6 0
5 3
4 2
3 2
2 4
1 5
....
....
(X=6 means June, X=5 means May.....X=1 means January).
So for example, costs in May are 3% lower than costs in June. Costs in April are 2% lower than costs in May......Costs in January are 5% lower than costs in February.
What I want to do is to create a new column which would appear as follows:
X Y Z
6 0 0
5 3 3
4 2 5
3 2 7
2 4 11
1 5 16
....
....
So basically column Z is a cumulative change in percent relative to month 6 (June). So, costs in January are actually 16% lower than costs in June. Costs in February are actually 11% lower than costs in June.....
So, Z for month 6 simply equals Y6.
Z for month 5 = Y6 + Y5.
Z for month 4 = Y6 + Y5 + Y4.
.....
.....
Can someone help me do this in SAS? I'm not sure if I need some type of DO LOOP or not? Hopefully this makes sense.