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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.