Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: cumulative density by age from density var


From   Robert Drago <[email protected]>
To   [email protected]
Subject   st: cumulative density by age from density var
Date   Mon, 7 May 2012 12:44:49 -0400

Dear Statalist,
Apologies if this has already been answered (feel free to point to an
earlier thread!).

I have American Community Survey data on adults age 16-85, and have
added CDC survival probabilities for each individual year of age (i.e.
the density, which I label psurv). Starting with some arbitrary year
of age, say 25, I am trying to attach to all future years of age the
cumulative density from that age forward.

Statistically, the problem is simple: assign value psurv for age 25 to
age 25, multiply that value by psurv for age 26 and assign to age 26,
multiply the result by psurv for age 27 and assign to age 27, and so
forth.

Here's what I've tried: reduce the data to one observation for each
age with "by age, sort; gen nvals = _n==1"
I then did a recode and created a new var with psurv=1 for all
ages<25, then ran cumul, but cannot get that command to use the values
instead of the number of observations per age.

I also tried forvalues,  as in:
gen psurv25 = psurv
recode psurv25 (0/1=1) if age<25
forvalues whatage=25/85{
replace psurv25 = psurv25*psurv if age = `whatage'
}

but if isn't allowed...

Any help greatly appreciated, Bob


--
Robert Drago, Ph.D.
1803 BIltmore St NW, #702
Washington DC 20009
ph 814-883-9907
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index