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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: Data management question for survival analysis problem |

Date |
Mon, 13 Apr 2009 22:07:17 +0200 |

<> Sounds like a case for the -sum()- function ************* clear* inp ID VI AGE CONTVAR BINVAR 1 1 60 . . 1 2 62 . . 1 3 66 12 0 1 4 67 14 0 1 5 72 17 1 2 1 60 20 1 2 2 62 . . 2 3 66 12 0 3 1 60 22 1 3 2 62 12 0 3 3 66 16 0 3 4 67 18 1 3 5 72 19 1 4 1 60 22 1 4 2 62 24 1 4 3 66 25 1 end compress l, sepby(ID) bys ID: gen TDVAR=sum(BINVAR) l, sepby(ID) ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von MAY BAYDOUN Gesendet: Montag, 13. April 2009 21:59 An: statalist@hsphsun2.harvard.edu Betreff: st: Data management question for survival analysis problem Dear Statalisters, I am trying to do the following so I can run survival analysis using a person-period file. I have data with id and visits and each visit is related to a particular which is the time variable. I have a variable that changes over visits and has a cutpoint at 16. I changed this variable from continuous to binary (<=16:0 and >16: 1). Now, I want to create a time-dependent variable, in such a way that if someone is zero for all visits, he/she is zero. If they become "1" at a visit, they are 1 in subsequent visits unless they score another "1" in which case, they become a "2". I don't want to have missing values for this new variable. What is the easiest way to do this? Below is an example: ID VI AGE CONTVAR BINVAR TDVAR 1 1 60 . . . 1 2 62 . . . 1 3 66 12 0 0 1 4 67 14 0 0 1 5 72 17 1 1 2 1 etc. 20 1 1 2 2 . . 1 2 3 12 0 1 3 1 22 1 1 3 2 12 0 1 3 3 16 0 1 3 4 18 1 2 3 5 19 1 3 4 1 22 1 1 4 2 24 1 2 4 3 25 1 3 Thanks for any help you can provide. Sincerely yours, May May Baydoun, PhD in Epidemiology (UNC-Chapel Hill) Staff Scientist, National Institute on Aging, NIH/IRP, Biomedical Research Center, Baltimore, MD * * 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/

**References**:**st: Data management question for survival analysis problem***From:*MAY BAYDOUN <mbaydoun2002@yahoo.com>

- Prev by Date:
**st: Data management question for survival analysis problem** - Next by Date:
**st: AW: RE: AW: summarize variables without collapsing** - Previous by thread:
**st: Data management question for survival analysis problem** - Next by thread:
**st: AW: Data management question for survival analysis problem** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |