Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: question about discrete time variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: question about discrete time variables
Date   Sun, 5 Oct 2003 18:01:20 +0100

martine 
 
> How do I make discrete times for my dates of visit (eg. I 
> want the data to 
> look like this:
> 
> id1 viralload cd4 etc.
> 
> t1    0
> t2    1
> t3    1
> 
> id2
> 
> t1    0
> t2    1
> 
> id3
> 
> t1
> t2
> t3
> 
> I have been trying to find this in STATA help, my STATA 
> book, and still cannot 
> find how I need to change the dates to discrete times.

I'm unclear what criterion it is that makes t1, t2, t3

0 1 1 

0 1 

etc. 

If the criterion is "second visit or later" 
then presumably you have a time variable, so 
can go 

bysort id1 (time) : gen secondorlater = _n > 1 

If on the other hand, you really mean 

0 1 2 

0 1 

etc. then you can go 

bysort id1 (time) : gen discretetime = _n - 1 

Nick 
[email protected] 

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