BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Birgithj
Fluorite | Level 6

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. 

 

YearAnnual returnStock price development
17,00%107,0
26,00%113,4
32,00%115,7
41,00%116,8
52,00%119,2
64,00%123,9
75,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? 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
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;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
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;
--
Paige Miller
Birgithj
Fluorite | Level 6

Thank you so much. Once again you have saved my day!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1139 views
  • 0 likes
  • 2 in conversation