Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: stsplit for for data with multiple records per subject


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: stsplit for for data with multiple records per subject
Date   Wed, 23 Dec 2009 06:31:24 +0800

...


Try this and check that the time-dependent variables are on the right
record.

drop _st-_t0

sort study_id dx_to_claim_day
by study_id: gen last = (_n==_N)
expand 2 if last==1
gen time = dx_to_claim_day

sort study_id dx_to_claim_day

by study_id: replace time = days if _n==_N
by study_id: replace died_1yr = 0 if _n<_N

stset time, failure(died_1yr) id(study_id)

gsort study_id -time

foreach var of varlist dual_15_85_12mth  va_pcnt dual_15_85_claims
cross_over  {
   by study_id: replace `var' = `var'[_n+1]
}

sort study_id -time

drop if _t==.




-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Weichle,
Thomas
Sent: Wednesday, 23 December 2009 5:35 AM
To: [email protected]
Subject: st: RE: stsplit for for data with multiple records per subject

I used the following stset command.  Then I merged a dataset which
contains multiple records per person which contains the vars after _t0.
I would like to split the data at the points where cross_over = 1.  This
represents that an individual switched from non-dual to dual user by our
definition or vice-versa (dual to non-dual user).  As you can see this
can happen multiple times in the study period (i.e. at 51, 232, and 260
days).  So for this individual, the data would be split 3 times
resulting in intervals of 0-51, 51-232, 232-260, and 260-365.25.  This
is what I would ideally like to see but I'm having trouble with the
stsplit syntax.

stset days, id(study_id) failure(died_1yr == 1) scale(365.25)

study_id	died_1yr	days		_st	_d	_t
_t0	dual_15_85_12mth	va_pcnt	dual_15_85_claims
dx_to_claim_day	cross_over	   
1		0		365.25	1	0	1	0
1			0		0			0
0	   
1		0		365.25	1	0	1	0
1			0		0			2
0	   
1		0		365.25	1	0	1	0
1			0		0			7
0	   
1		0		365.25	1	0	1	0
1			0.2		1			51
1	   
1		0		365.25	1	0	1	0
1			0.16666667	1			113
0	   
1		0		365.25	1	0	1	0
1			0.14285714	0			232
1	   
1		0		365.25	1	0	1	0
1			0.125		0			243
0	   
1		0		365.25	1	0	1	0
1			0.22222222	1			260
1	   
1		0		365.25	1	0	1	0
1			0.2		1			301
0	   
1		0		365.25	1	0	1	0
1			0.18181818	1			356
0	


Tom Weichle
Math Statistician
Center for Management of Complex Chronic Care (CMC3)
Hines VA Hospital, Bldg 1, C202
708-202-8387 ext. 24261
[email protected] 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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