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

Hello,

How do I Calculate   Product on each level?

Data like this

     t   d   y           Prod (1-d/y)   

     6  3   21         (1-3/21)

     7  1   17          (1-3/21)(1-1/17)    and so on...

     10 1   15

     13 1   12

     16 1   11

     22 1    7

     23 1    6

     ....

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Is this what you want?

data want ;

  input t d y ;

  retain prod 1 ;

  prod = prod*(1-d/y);

cards;

     6 3   21         (1-3/21)

     7 1   17          (1-3/21)(1-1/17)    and so on...

     10 1 15

     13 1 12

     16 1 11

     22 1 7

     23 1 6

;;;;

data _null_;

  set ;

  put (_all_) (:);

run;

6 3 21 0.8571428571

7 1 17 0.8067226891

10 1 15 0.7529411765

13 1 12 0.6901960784

16 1 11 0.6274509804

22 1  7 0.5378151261

23 1  6 0.4481792717

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Is this what you want?

data want ;

  input t d y ;

  retain prod 1 ;

  prod = prod*(1-d/y);

cards;

     6 3   21         (1-3/21)

     7 1   17          (1-3/21)(1-1/17)    and so on...

     10 1 15

     13 1 12

     16 1 11

     22 1 7

     23 1 6

;;;;

data _null_;

  set ;

  put (_all_) (:);

run;

6 3 21 0.8571428571

7 1 17 0.8067226891

10 1 15 0.7529411765

13 1 12 0.6901960784

16 1 11 0.6274509804

22 1  7 0.5378151261

23 1  6 0.4481792717

rimal6_netscape_net
Calcite | Level 5

Thank you,

             Exactly what I wanted.

Regards

Mahesh

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1238 views
  • 0 likes
  • 2 in conversation