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

st: RE: RE: Generating unique admission id


From   "Kallimanis, Bellinda" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Generating unique admission id
Date   Tue, 13 Dec 2005 09:33:03 -0500

Hi!

I have a follow up question from the other day. I now have a LOS
variable I'm very happy with, but now I want to tell Stata to create a
marker when LOS is closest to 6 months (182 days but with a range from
122 - 272 days) for an observation and only if that observation is a
quarterly or significant change assessment.
At the moment my data looks like this and I want to create the "marker"
variable

id              aa8a   target     mth6_fu      los  marker	
1         adm assess   07may2003      .         0  	.
1       quart review   20jul2003      .        74  	.
1       quart review   12oct2003      1       158  	1
1       quart review   04jan2004      1       242  	.
1         ann assess   28mar2004      .       326   	.
2         adm assess   16oct2000      .         0  	.
2         sig change   25mar2001      1       160  	1
2   dis - NO ant ret   28mar2001      .       163  	.
3         adm assess   17oct2000      .         0   	.
3       quart review   09jan2001      .        84  	.
3      dis - ant ret   14feb2001      .       120  	.
3       quart review   02apr2001      1       167  	1
3   dis - NO ant ret   14may2001      .       209    	.
4         adm assess   02feb2003      .         0  	.
4       quart review   21apr2003      .        78  	.
4       quart review   07jul2003      1       155  	1
4         sig change   21sep2003      1       231  	.
4         ann assess   07dec2003      .       308  	.

The rules for creating this variable are if there are 2 assessments I
would prefer the quarterly if it is a choice between a quarterly and a
significant change assessment, if there are two and they are the same
type of assessment I want the one closest to 182 days. I've tried
creating all sorts of variables to help me, but I still can't quite get
at what I want. Any help would be greatly appreciated and any references
to data management with panel data would also be really helpful!
Thank you in advance.

Cheers,
Bellinda





-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Friday, December 09, 2005 10:37 AM
To: [email protected]
Subject: st: RE: Generating unique admission id

A unique admission id is 

bysort resident (time) : 
	gen adm_id = sum(inlist(aa8a, "adm asses", "reentry"))  

Then los sounds like 

bysort resident adm_id (time) : 
	gen los = time - time[1] 

Nick 
[email protected] 

Kallimanis, Bellinda
 
> I have a data manipulation question. I have a large data set (panel
> format) and I am trying to calculate length of stay for each 
> individual.
> The thing is many individuals come in (adm asses) and stay then leave
> (disch) then come back. But to complicate it more, some people leave
> with anticipated return (dis_ret) then come back (reentry) and some
> people are admitted and have follow up but have not been discharged.
> What I would like to do is create a variable that has LOS for each
> separate admission. Below is a sample of my data
> 
> 
>    resident   target              aa8a         LOS (what I want to
> create)
>           1   30sep2001           adm asses	0
>           1   10oct2001           disch   	10
>           1   18nov2002           adm asses  	0
>           1   22nov2002           disch  		4
>           1   18jul2004           adm asses  	0
>           1   28jul2004           disch  		10
>           2   07may2003           adm asses  	0
>           2   20jul2003        quart review  	74
>           2   12oct2003        quart review  	158
>           2   04jan2004        quart review  	242
>           2   28mar2004           ann asses  	326
>           2   20jun2004        quart review  	410
>           2   12sep2004        quart review  	494
>           3   15oct2000           adm asses  	0
>           3   23oct2000           dis_ret  	8
>           3   25oct2000           reentry  	0
>           3   22nov2000           disch  		28
>           4   17oct2000           adm asses  	0
>           4   01nov2000           disch  		15
>           5   15oct2000           adm asses  	0
>           5   22nov2000           disch 		38
>           
> 
> I created a flag for any type of discharge and I think if I create a
> unique id for each admission that I would be able to 
> calculate the LOS.
> I'm just not sure how to get this admission id or whether there is
> another way I could do this. 

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

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