Hi - I would like to calculate the net present value of a series of cash flows by loanID and by year. For example, for loanID 1 below, I would like the NPV at Year 0 of all the cash flows from Year 1 through Year 5, then the NPV at Year 1 of all the cash flows from Year 2 through Year 5, etc. Any assistance is greatly appreciated. Thank you!
* Example generated by -dataex-. To install: ssc install dataex clear input byte loanID float year long cash_flow float disc_rate 1 1 10000 .15 1 2 20000 .1 1 3 30000 .12 1 4 40000 .14 1 5 50000 .15 2 1 1000 .15 2 2 2000 .1 2 3 3000 .12 2 4 4000 .14 2 5 5000 .15 end
* Example generated by -dataex-. To install: ssc install dataex clear input byte loanID float year long cash_flow float disc_rate 1 1 10000 .15 1 2 20000 .1 1 3 30000 .12 1 4 40000 .14 1 5 50000 .15 2 1 1000 .15 2 2 2000 .1 2 3 3000 .12 2 4 4000 .14 2 5 5000 .15 end
Comment