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!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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