Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: R: Survival Data - Compare hazards by matching on age (flag: Stata 9.2/SE)

 From asb stata To statalist@hsphsun2.harvard.edu Subject Re: st: R: Survival Data - Compare hazards by matching on age (flag: Stata 9.2/SE) Date Tue, 9 Mar 2010 19:51:08 -0500

```I want to clarify that I want to plot is the percentage of subjects that
survive among the total number of subjects that have entered so far. This is
trivial in Group 2 where there is no entry of subjects after age one. So, in
group 2, I am interested in what percentage of 100 subjects survive at each
age starting age 1.

In group 1, however, there is entry (variable flag=1) as well as exit at
each age. If there are 100 subjects in total, their entry is staggered over
time. 25 subjects may enter at age 3 and become at risk of dying. Out of
these 25, 5 may die at age four but 20 may enter bringing the total number
of entering subjects to 45 (which is my changing denominator). Entry will
continue till cumulative entry is 100. At the same time exit also continues.
Each period, in group1, I want to know what fraction of the total number of
entering subjects (such as 45 at age 4) survive into the next period.

I am not sure how to handle this difference between the two groups as I try
to plot one K-M graph that has both curves. Even if I can deal with them
separately and add to a plot, that would also work. Any help?

On Tue, Mar 9, 2010 at 2:30 PM, asb stata <asb.stata@gmail.com> wrote:

> Carlo,
>
> I think the trick is to compare survivors of the same age across the two
> groups. Let me explain:
>
> In group 1, subjects are sure to survive till a certain age unlike in group
> 2 where they are at risk since age 1. Suppose there are 100 subjects in
> group 1 and they all survive till age 3 and then some, say ten, come under
> risk and five die and 95 go on to age 4. Suppose there are another 100 in
> group 2 and they start dying right away and only 50 survive at the beginning
> of age 3 and another 10 die and 40 go on to age 4. Among survivors of age 3
> across the two groups, 95% survive in group 1 (95 survive among 100) and 80%
> survive in group 2 (40 survive among 50). I want to plot these percentages
> of survivors at each age for the two groups. The data is in
> multiple-records-per-subject format as shown below. The important variable
> is flag which identifies when a subject in group 1 becomes at risk.
> Subject id=1 is not at risk until period 2. I need to know how to stset and
> also how to sts graph. Something like:
>
> stset age, id(id) failure(died=1)
>
> sts graph, by(group) ........?
>
> asb
>   On Tue, Mar 9, 2010 at 11:25 AM, Carlo Lazzaro <carlo.lazzaro@tin.it>wrote:
>
>> Asb stata wrote:
>> "I want to compare the hazard of exit for the two
>> groups by comparing subjects of the same age across groups. How do I do it
>> in stata?"
>>
>> The following:
>> - sts test group, logrank strata(age) -
>>
>> may do the trick.
>>
>> Kind Regards,
>> Carlo
>>
>> -----Messaggio originale-----
>> Da: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di asb stata
>> Inviato: martedě 9 marzo 2010 8.02
>> A: statalist@hsphsun2.harvard.edu
>> Oggetto: st: Survival Data - Compare hazards by matching on age
>>
>> There are two groups of subjects in my data. In the first group, all
>> subjects are at risk of dying since age 1. In the second group, each
>> subject
>> becomes at risk of dying from a subject-specific age different from 1. I
>> want to stset the data properly and graph Kaplan-Meier survival curves for
>> the two groups. A sample of data is presented below. id is unique subject
>> id. group is 1 if subjects do not become at risk of dying until flag=1.
>> Subject 1 becomes at risk of dying only at age 2 or after unlike subjects
>> 3
>> and 4 which become at risk of dying at age 1. died indicates the actual
>> failure event. The data is set as multiple-record-per-subject. I do not
>> want
>> to compare the hazard of exit of the two groups without taking into
>> account
>> the fact that the members of the first group do not become at risk until a
>> certain (variable) age. I want to compare the hazard of exit for the two
>> groups by comparing subjects of the same age across groups. How do I do it
>> in stata? How to match subjects by age and compare hazard of exit? Is
>> there
>> another way besides matching on age?
>>
>> id        group        flag        age        died
>> 1           1             0            1            0
>> 1           1             1            2            0
>> 1           1             1            3            0
>> 1           1             1            4            1
>> 2           1             0            1            0
>> 2           1             0            2            0
>>  2           1             0            3            0
>> 2           1             0            4            0
>>  2           1             1            5            0
>> 2           1             1            6            1
>> 3           2             1            1            0
>> 3           2             1            2            0
>> 3           2             1            3            1
>> 4           2             1            1            0
>> 4           2             1            2            0
>> 4           2             1            3            0
>> 4           2             1            4            0
>> 4           2             1            5            1
>>
>> *
>> *   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/
>>
>>
>> *
>> *   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/
>>
>
>
*
*   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/```