Hello Statalist,
I am trying to find the longest duration between 2 dates per episode per member.
Background: I have hospital claims data and I am ultimately trying to assess average lengths of stay in hospital. The problem is that multiple lines of claims can be generated for each episode of stay for a member. I would like to identify the longest of these claims for each given episode and use that for my average length of stay calculation.
The variables I have are member id (mem_ckey), starting date of service (from_dt) and ending date of service (to_dt).
What I am trying to generate is the following:
The 2 variables I need to generate are length of stay (LOS) and an indicator of whether the stay was the longest stay among a set of overlapping stays (longest). The LOS is relatively easy, but the longest variable I am not so sure about. May I please get some help?
Thanks!
I am trying to find the longest duration between 2 dates per episode per member.
Background: I have hospital claims data and I am ultimately trying to assess average lengths of stay in hospital. The problem is that multiple lines of claims can be generated for each episode of stay for a member. I would like to identify the longest of these claims for each given episode and use that for my average length of stay calculation.
The variables I have are member id (mem_ckey), starting date of service (from_dt) and ending date of service (to_dt).
What I am trying to generate is the following:
The 2 variables I need to generate are length of stay (LOS) and an indicator of whether the stay was the longest stay among a set of overlapping stays (longest). The LOS is relatively easy, but the longest variable I am not so sure about. May I please get some help?
mem_ckey | from_dt | to_dt | LOS | longest |
1 | 13APR2007:00:00:00.000000 | 16APR2007:00:00:00.000000 | 3 | 1 |
1 | 13APR2007:00:00:00.000000 | 14APR2007:00:00:00.000000 | 1 | 0 |
1 | 10MAY2007:00:00:00.000000 | 19MAY2007:00:00:00.000000 | 9 | 1 |
2 | 28FEB2013:00:00:00.000000 | 04MAR2013:00:00:00.000000 | 5 | 0 |
2 | 27FEB2013:00:00:00.000000 | 04MAR2013:00:00:00.000000 | 6 | 1 |
2 | 28FEB2013:00:00:00.000000 | 03MAR2013:00:00:00.000000 | 4 | 0 |
Comment