Hi,
I have dataseries containing annual percentage growth, and from this I would like to create a new column showing corresponding price development (assuming a price of 100 in year 0). An example can be seen below.
Year | Annual return | Stock price development |
1 | 7,00% | 107,0 |
2 | 6,00% | 113,4 |
3 | 2,00% | 115,7 |
4 | 1,00% | 116,8 |
5 | 2,00% | 119,2 |
6 | 4,00% | 123,9 |
7 | 5,00% | 130,1 |
I have used the following code, but I am not able to successfully do the calculation.
data want;
set have;
if first.return then Price=100;
Price*(1+return);
run;
Can someone please help me?
data have;
input year return;
if _n_=1 then price=100;
price+price*(return/100);
cards;
1 7
2 6
3 2
4 1
;
run;
data have;
input year return;
if _n_=1 then price=100;
price+price*(return/100);
cards;
1 7
2 6
3 2
4 1
;
run;
Thank you so much. Once again you have saved my day!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.