Statalist The Stata Listserver


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

RE: st: A question on using survival model


From   James Harris <[email protected]>
To   [email protected]
Subject   RE: st: A question on using survival model
Date   Sun, 27 May 2007 09:23:18 +1200

You could classify visits by when they happen, then collapse your data to count visits within each time range.
I've been doing something similar to track time since first hospitalisation.

assuming data like
ID Date

// create a visit count
gen Visit = 1

// create sequences
bysort ID Date: gen VisitNum = _n // or reverse sort on Date if you want time since last visit.

gen TimeOfFirst = Date if VisitNum == 1
replace TimeOfFirst = TimeOfFirst[_n-1] if VisitNum > 1 // carry forward
gen TimeSinceFirst = Date - TimeOfFirst // can be zero


// now you can classify visits by time since first visit, eg
gen Stage = 1 if TimeSinceFirst < 30
label define StageLabel ///
1 "30 days"
label values Stage StageLabel

// Finally, you can tablulate or collapse data
collapse (count) Visit, by ID Stage

// you now have a dataset that shows number of visits in each period for each person

Hope that helps. You could probably do something similar with stset, and then use the _t variables. The method above may be slightly more generalisable.


- James

*From* "Chunling Lu" <[email protected] <mailto:[email protected]>>
*To* <[email protected] <mailto:[email protected]>>
*Subject* st: A question on using survival model
*Date* Thu, 24 May 2007 12:25:55 -0400

------------------------------------------------------------------------

Dear all,

I have a question "When was the last time you visited doctor" with the
following categories: (1) in the last 30 days, (2) between 1 month and less
than 1 year ago. I now would like to derived the average number of visits
for last 30 days. How should I model it and how can I do it in stata?

Any suggestions are highly appreciated.
Chunling


*
* 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/




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