[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Jan Brøgger <Jan.Brogger@nevro.uib.no> |

To |
<statalist@hsphsun2.harvard.edu>, <james_harris@paradise.net.nz> |

Subject |
st: Using sts list results in do-files |

Date |
Mon, 3 Mar 2008 21:48:51 +0100 |

There was a previous post on Statalist by James Harris about getting the results of -sts list- into a format accessible to Stata programs. I've made a small program that does just this, preliminary called st_survat. You'd call it with stset data and after generating a survival variable with stgen. It uses previous Statalist suggestions about using "stgen" but has a little logic to select the next earlier time point if the wanted time point isn't actually in the dataset. The use case is where you want to mass-produce summaries of survival-level data in a table. It's a quickie, and I can't write Stata help files so I prefer to post it here (too many {(/*'}). If anybody wants to embellish it with help files and a -sysuse- example, I'd be happy. I may get around to it. *This program returns the survival at a given time point *in an r-class macro, making results like "sts list" *accessible by a Stata program *Requirements: * 1) data is stset * 2) a survival variable has been generated using stgen program define st_survat , rclass syntax [if], at(real) survvar(varlist min=1 max=1) st_is 2 full if "`if'"!="" { local if " & `if'" } /* Check if we have an exact match on the time scale */ qui summ `survvar' if _t==`at' & _t<=`at' `if' if `r(N)'==0 { *no match, so get the next smallest match qui summ _t if _t<=`at' `if' local time=`r(max)' } else { local time=`at' local surv "`r(min)'" } /* Get the survival at the best time match */ qui summ `survvar' if _t==`time' `if' local surv=`r(min)' di "surv at `at' (same as `time') is `surv'" return scalar at=`at' return scalar t=`time' return scalar survival=`surv' end Yours, Jan Brogger, postdoc University of Bergen * * 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/

- Prev by Date:
**st: Measure of Variability in a Nominal Variable** - Next by Date:
**Re: st: coding question** - Previous by thread:
**st: Measure of Variability in a Nominal Variable** - Next by thread:
**Re: st: coding question** - Index(es):

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