Greetings Statlist users,
I could use some assistance with a seemingly simple loop.
As the merged datasets that I'm working with are panel, some values may be repeats. In this case I am essentially trying to loop through each unique patient (designated by "PAT_ENC_CSN") and tally the total number of days spent in 8D (designated by "days8D"). However, I also need to consider unique stays/time spent within 8D as some patients come and go through the unit during their overall stays (designated "stay").
So, essentially need a loop that totals days8D per unique "PAT_ENC_CSN" and unique "stay".
For the example patient below, total days in 8d would equal 15.
Thanks,
Todd
I could use some assistance with a seemingly simple loop.
As the merged datasets that I'm working with are panel, some values may be repeats. In this case I am essentially trying to loop through each unique patient (designated by "PAT_ENC_CSN") and tally the total number of days spent in 8D (designated by "days8D"). However, I also need to consider unique stays/time spent within 8D as some patients come and go through the unit during their overall stays (designated "stay").
So, essentially need a loop that totals days8D per unique "PAT_ENC_CSN" and unique "stay".
For the example patient below, total days in 8d would equal 15.
PAT_ENC_CSN | adm_date | dc_date | days8D | stay |
2.51E+08 | 31-Jan-19 | 31-Jan-19 | 1 | 1 |
2.51E+08 | 8-Feb-19 | 18-Feb-19 | 11 | 2 |
2.51E+08 | 23-Feb-19 | 25-Feb-19 | 3 | 3 |
2.51E+08 | 23-Feb-19 | 25-Feb-19 | 3 | 3 |
2.51E+08 | 23-Feb-19 | 25-Feb-19 | 3 | 3 |
2.51E+08 | 23-Feb-19 | 25-Feb-19 | 3 | 3 |
2.51E+08 | 23-Feb-19 | 25-Feb-19 | 3 | 3 |
2.51E+08 | 23-Feb-19 | 25-Feb-19 | 3 | 3 |
Todd
Comment