Hi.
I am trying to calculate the present value of a person's earnings given expected time s/he will live for.
id age earnings lifeExpec discrate
1 25 50000 50 1.017
2 70 40000 10 1.017
3 33 32000 28 1.017
Since forvalues command does not take variables as maximum number for the loop, how do I calculate present value of expected lifetime earnings?
For example, I would like to calculate the result of the following code.
forvalues i=1/`lifeExpec' {
egen pv = sum(earnings/(discrate)^`i')
}
Thanks.
I am trying to calculate the present value of a person's earnings given expected time s/he will live for.
id age earnings lifeExpec discrate
1 25 50000 50 1.017
2 70 40000 10 1.017
3 33 32000 28 1.017
Since forvalues command does not take variables as maximum number for the loop, how do I calculate present value of expected lifetime earnings?
For example, I would like to calculate the result of the following code.
forvalues i=1/`lifeExpec' {
egen pv = sum(earnings/(discrate)^`i')
}
Thanks.
Comment