Statalist


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

Re: st: Coding time-varying variables in Cox regression


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Coding time-varying variables in Cox regression
Date   Tue, 10 Jun 2008 07:28:08 +0100 (BST)

*------------------- begin example -------------------------------
drop _all
input id   time   died   TREAT1  TREAT2   TREAT3    TREAT4
      1    42     0      5       17       23        8
      2    56     1      9       3        22        16
      3    12     1      7       11       6         .
end
stset time, failure(died) id(id)
stsplit period, at(6 12 24)

bys id (period): gen treat = TREAT1 if _n == 1
forvalues i = 2/4 {
	bys id (period): replace treat = TREAT`i' if _n == `i'
}
list
*----------------------- end example ----------------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

In the code above I made a variable treat, in subsequent analysis you
use the variable treat instead of TREAT1-TREAT4.

Hope this helps,
Maarten

--- Allan Garland <agar5858@shaw.ca> wrote:

> Salah,
> 
> Thanks for your answer.  The problem with that solution is that I
> need to separately assess the impact of each treatment.  Any other
> ideas?
> 
> Allan
> *
> *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index