Save max/min x/y/z position of a group of particles to a variable?

My simulation has 3 groups of particles. I’d like to have it save the maximum z position (at the final time step) of the group 2 particles to, say, a variable that I can write to the log file. What commands in my input file could I use to do this? Any and all help would be greatly appreciated!

You can determine such global properties from groups individual atoms using the compute reduce command. Results from computes can be output in different ways including being assigned to a variable. Please see here in the manual for a starting point.