Statalist The Stata Listserver


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

st: RE: Excluding Observations


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Excluding Observations
Date   Mon, 15 May 2006 22:52:02 +0100

A visit results in a transfusion whenever t is 1. 

gen ttime = dov if t == 1 

This results in missings whenever t is 0. 
Hence we fill in missings following the 
usual cascade principle documented at
http://www.stata.com/support/faqs/data/missing.html

bysort id (dov): replace ttime = ttime[_n-1] if mi(ttime) 

Here I am assuming that you want each patient treated
separately. 

Then the time since the last transfusion is simply 

gen sincettime = dov - ttime 

Then you can exclude whatever you want. You have
to work out what to do with observations before
the first transfusion (on record). 

-etime- is superfluous here. 

Nick 
[email protected] 

Raphael Fraser
 
> I would like to exclude from my data set all observations up to 90
> days AFTER a transfusion (i.e. t = 1). The variable etime is the  time
> elapse since last visit. Can any one help?
> 
>          id         dov   t   etime
>      57   26apr1977   0      57
>      57   27apr1977   0       1
>      57   28jun1977   0      62
>      57   27jul1977   0      29
>      57   19aug1977   1      23
>      57   12sep1977   0      24
>      57   27sep1977   0      15
>      57   30nov1977   0      64
>      57   28feb1978   0      90
>      57   22jan1990   0      55
>      57   23jan1990   0       1
>      57   22jun1990   0     150
>      57   01aug1990   0      40
>      57   06aug1990   0       5
>      57   12sep1990   1      37
>      57   19sep1990   0       7
>      57   21sep1990   0       2
>      57   28sep1990   0       7
>      57   14nov1990   0      47
>      57   28nov1990   0      14
>      57   21jan1991   0      54
>      57   29apr1991   0      98
>      57   23aug1991   0     116
>      57   29aug1991   0       6
>      57   20sep1991   0      22
>      57   30sep1991   0      10
>      57   28nov1991   0      59
>      57   20jan1992   0      53
>      57   21jan2002   0      35
>       57   27may2002   0     126
>      57   31may2002   0       4
>      57   07jun2002   0       7
>      57   09jul2002   0      32
>      57   09oct2002   0      92
>      63   28dec1974   0       0
>      63   29dec1974   0       1
>      63   08jan1975   0      10
>      63   15may1975   0     127
>      63   30jun1975   0      46
>      63   29dec1975   0     182
>      63   12jan1976   0      14
>      63   19jan1976   0       7
>      63   30mar1976   0      71
>      63   28jun1976   0      90
>      63   22oct1976   0     116
>      63   25oct1976   0       3
>      63   24nov1976   1      30
>      63   04dec1976   0      10
>      63   06dec1976   0       2
>      63   21dec1976   0      15
>      63   21jan1977   0      31
>      63   26jan1977   0       5
>      63   18feb1977   0      23
>      63   28mar1977   0      38
>      63   31may1977   0      64
>      63   13jun1977   0      13
>      63   28jun1977   0      15
>      63   31aug1977   0      64
>      63   03sep1977   0       3
>      63   06sep1977   0       3
>      63   27sep1977   0      21
>      63   07oct1977   0      10
>      63   05nov1977   0      29
>      63   08nov1977   0       3
>      63   27nov1977   0      19
>      63   07dec1977   0      10
>      63   16dec1977   0       9
>      63   18dec1977   0       2
>      63   19dec1977   0       1
>      63   10jan1978   0      22
>      63   11jan1978   0       1
>      63   12jan1978   0       1
>      63   14feb1978   1      33
>      63   22feb1978   0       8
>      63   28feb1978   0       6
>      63   17mar1978   0      17
>      63   04apr1978   0      18
>      63   07jun1978   0      64
>      63   26jun1978   0      19
>      63   14jul1978   0      18
>      63   21jul1978   0       7
>      63   09aug1978   0      19
>      63   14aug1978   0       5
>      63   11sep1978   0      28
>      63   24sep1979   0      17
>      63   27sep1979   0       3
>      63   29sep1979   1       2
>      63   14dec1979   0      76
>      63   07jan1980   0      24
>      63   21sep1982   0      46
>      63   04oct1982   0      13
>      63   17dec1982   0      74
>      63   22dec1982   0       5
>      63   25dec1982   0       3
>      63   01jan1983   0       7
>      63   04jan1983   0       3
>      63   24jan1983   0      20
>      63   15mar1983   0      50
>      63   28jun1983   0     105
>      63   28sep1983   0      92
>      63   04oct1983   0       6
>      63   09jan1984   0      97
>      63   30jan1984   0      21
>      63   28mar1984   0      58
>      63   28jun1984   0      92
>      63   01oct1984   0      95
>      63   16oct1984   0      15
>      63   20dec1984   0      65
>      63   24dec1984   0       4
>      63   03jan1985   0      10
>      63   08jan1985   0       5
>      63   27mar1985   0      78
>      63   30apr1985   0      34
>      63   01may1985   1       1
>      63   13may1985   0      12
>      63   14may1985   0       1
>      63   11jun1985   0      28
>      63   02jul1985   0      21
>      63   19aug1985   0      48
>      63   23sep1985   0      35
>      63   01oct1985   0       8
>      63   18oct1985   0      17
>      63   24oct1985   0       6
>      63   03dec1985   0      40

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