I bet this topic has been covered in a previous post. I've searched and looked through the forum but without luck.
I have a large dataset that contains date+time for admissions and discharges from hospital departments.
I have grouped them and would like to identify the time of first admission and time of last discharge so I can tell how long the total hospital stay has been.
ID represents a unique patient but can be represented with more than one group of admissions/discharges.
I would like to identify the time of first admission and time of last discharge.
Example:
- for ID 2 I would like to identify: in_time 22/02/2017 08:54:00 and out_time 27/02/2017 11:00:00
- for ID 4 I would like to identify: in_time 01/03/2008 03:42:00 and out_time 11/03/2008 02:30:00
ID...in_time.........................out_time..... .................group
1....11/06/2012 07:37:00....11/06/2012 08:37:00....1
1....11/06/2012 08:37:00....11/06/2012 11:10:00....1
1....17/12/2015 11:32:00....18/12/2015 09:30:00....2
1....18/12/2015 09:30:00....21/12/2015 01:40:00....2
2....22/02/2017 08:54:00....23/02/2017 10:00:00....1
2....23/02/2017 10:00:00....25/02/2017 08:30:00....1
2....25/02/2017 08:30:00....27/02/2017 11:00:00....1
3....09/05/2013 09:24:00....11/05/2013 01:22:00....1
3....11/05/2013 01:22:00....13/05/2013 12:40:00....1
4....12/04/2014 04:40:00....14/04/2014 05:45:00....1
4....14/04/2014 05:45:00....21/04/2014 11:20:00....1
4....01/03/2008 03:42:00....03/03/2008 10:45:00....2
4....03/03/2008 10:45:00....05/03/2008 03:40:00....2
4....05/03/2008 03:40:00....05/03/2008 07:52:00....2
4....05/03/2008 07:52:00....06/03/2008 09:00:00....2
4....06/03/2008 09:00:00....06/03/2008 11:30:00....2
4....06/03/2008 11:30:00....08/03/2008 08:35:00....2
4....08/03/2008 08:35:00....11/03/2008 02:30:00....2
I would be grateful if someone could post a possible solution to this problem.
Thank you in advance.
I have a large dataset that contains date+time for admissions and discharges from hospital departments.
I have grouped them and would like to identify the time of first admission and time of last discharge so I can tell how long the total hospital stay has been.
ID represents a unique patient but can be represented with more than one group of admissions/discharges.
I would like to identify the time of first admission and time of last discharge.
Example:
- for ID 2 I would like to identify: in_time 22/02/2017 08:54:00 and out_time 27/02/2017 11:00:00
- for ID 4 I would like to identify: in_time 01/03/2008 03:42:00 and out_time 11/03/2008 02:30:00
ID...in_time.........................out_time..... .................group
1....11/06/2012 07:37:00....11/06/2012 08:37:00....1
1....11/06/2012 08:37:00....11/06/2012 11:10:00....1
1....17/12/2015 11:32:00....18/12/2015 09:30:00....2
1....18/12/2015 09:30:00....21/12/2015 01:40:00....2
2....22/02/2017 08:54:00....23/02/2017 10:00:00....1
2....23/02/2017 10:00:00....25/02/2017 08:30:00....1
2....25/02/2017 08:30:00....27/02/2017 11:00:00....1
3....09/05/2013 09:24:00....11/05/2013 01:22:00....1
3....11/05/2013 01:22:00....13/05/2013 12:40:00....1
4....12/04/2014 04:40:00....14/04/2014 05:45:00....1
4....14/04/2014 05:45:00....21/04/2014 11:20:00....1
4....01/03/2008 03:42:00....03/03/2008 10:45:00....2
4....03/03/2008 10:45:00....05/03/2008 03:40:00....2
4....05/03/2008 03:40:00....05/03/2008 07:52:00....2
4....05/03/2008 07:52:00....06/03/2008 09:00:00....2
4....06/03/2008 09:00:00....06/03/2008 11:30:00....2
4....06/03/2008 11:30:00....08/03/2008 08:35:00....2
4....08/03/2008 08:35:00....11/03/2008 02:30:00....2
I would be grateful if someone could post a possible solution to this problem.
Thank you in advance.

Comment