I have cost data for three groups of patients and we want to see if there is a difference in costs before, during and after we implemented a change. The data is non-parametric and not paired, therefore I've used a Kruskal-Wallis test to compare medians. So far, so good.

However, my prof has now said he wants to know if there is any difference in costs for 30-day survivors only. And that as the hospital has spent the money, I somehow need to include the total cost, but exclude the number of deceased patients from the 'cost-per-survivor' analysis, so can't just exclude all data for deceased patients.

Getting a median cost per survivor seems easy (divide total costs in each group by just the number that survived in each group) but as the prof wants to know if there is a statistical difference between these costs, I'm a bit stuck!

I can't figure out how to run a fair test to compare the groups, excluding the deceased patients in the 'denominator' but including the costs these patients incurred in the 'numerator' (sorry for the incorrect use of terminology, but it seems to be the only way I can explain what I mean)

Any help would be most appreciated!