This should do it, if all of your -age- values are integer:
gen sum=0
local a = 1
local b = 1.5
forv i=1/65 {
replace sum=sum+`a'*`i'+`b'*(`i'^2) if age<=`i'
}
hth,
Jeph
Sayema Bidisha wrote:

Hi,

I am trying to get a function of age from a panel of households in STATA. I want to have a sum of a quadratic function (ax+bx^2) of age of a person until age 65: sum (ax+bx^2) where we need the sum of this function from his current age to age 65. For example if a person is 50 years old (x=50) and the predicated coefficient for age (a) is 1 and age square (b) is 1.5 then for him the estimated age function is =(50*1+50^2*1.5) + (51*1+51^2*1.5) + .............(65*1+65^2*1.5).It would be appreciated if anyone can tell me how to do this in STATA.

Thanks

Bidisha

This message has been checked for viruses but the contents of an attachment

may still contain software viruses, which could damage your computer system:

you are advised to perform your own checks. Email communications with the

University of Nottingham may be monitored as permitted by UK legislation.

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/