# st: stsplit and cumulative dose

 From Enzo Coviello <[email protected]> To [email protected] Subject st: stsplit and cumulative dose Date Fri, 23 Apr 2004 15:17:54 +0200

```At 12.33 22/04/04 +0100, you wrote:
```
Using stlexis (stata 5) I used to be able to split follow-up time
according to cumulative dose (x) of some exposure.

For example, I could convert these three records

id timein timeout xin xout fail
-------------------------------------------
1 0 5 0 40 0
1 5 10 40 180 0
1 10 15 180 220 1

into these five records

id timein timeout fail exp_grp
1 0.000 5.000 0 0-100
1 5.000 7.143 0 0-100
1 7.143 10.000 0 100-200
1 10.000 12.500 0 100-200
1 12.500 15.000 1 200-300

making the assumption of a linear increase in cumulative dose between

Somewhere along the line the contributed command stlexis was replaced by
the official command stsplit, but I can't figure out how to do this with
stsplit. Even worse, I can't figure out how to do it at all without going back to stlexis.

Dear prof Hills,

maybe this could an empirical solution:

. gen xoutcopy=xout

. stset xout,enter(xin) id(id) f(fail)

. stsplit exposure, at(100 200)
(2 observations (episodes) created)

. bysort id (xout) : replace timeout = timein+ (timeout-timein) * (_t-_t0) / (xoutcopy-_t0)

. bysort id (_t) : replace timein=timeout[_n-1] if _n>1

. stset timeout,enter(timein) id(id) f(fail)

. list id timein timeout xin xout exposure

+------------------------------------------------+
| id timein timeout xin xout exposure |
|------------------------------------------------|
1. | 1 0 5 0 40 0 |
2. | 1 5 7.14286 40 100 0 |
3. | 1 7.14286 10 40 180 100 |
4. | 1 10 12.5 180 200 100 |
5. | 1 12.5 15 180 220 200 |
+------------------------------------------------+

Enzo

^^^^^^^^^^^^^^^^
Enzo Coviello
Dipartimento di Prevenzione ASL BA/1
via L. Barbera 27 - 70055 MINERVINO MURGE (BA)
Italy
tel - fax +39 0883 691053
tel (home) +39 0883 695055
*
* 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/