SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yuwentaiwan
Calcite | Level 5

Obs  p

1    1

2    1

3    1.2

4    1

5    1.3

6    1

7    1

8    1.5

 

I want to this output,how can I calculate continuous multiplication?

Thanks!

Obs  p  cump

1    1     1

2    1     1(=1*1)

3    1.2    1.2(=1.2*1)

4    1     1.2(=1*1.2)

5    1.3   1.56(=1.3*1.2)

6    1     1.56

7    1     1.56

8    1.5    2.34(1.5*1.56)

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @yuwentaiwan 

 

Please try this:

data have;
	input Obs p;
	datalines;
1 1
2 1
3 1.2
4 1
5 1.3
6 1
7 1
8 1.5
;
run;

data want;
	set have;
	retain cump 1;
	cump = cump*p;
run;

View solution in original post

3 REPLIES 3
ed_sas_member
Meteorite | Level 14

Hi @yuwentaiwan 

 

Please try this:

data have;
	input Obs p;
	datalines;
1 1
2 1
3 1.2
4 1
5 1.3
6 1
7 1
8 1.5
;
run;

data want;
	set have;
	retain cump 1;
	cump = cump*p;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 3 replies
  • 815 views
  • 1 like
  • 2 in conversation