I want to take the value in a row and subtract the value in that group/category which is closest to 0. In other words, if I have a table
Col1 Col2
A -4
A -9
A 1
B 10
B 13
B 19
Everything in the A category should be Col2 – 1 (because 1 is the closest to zero in the A group). Everything in the B category should be Col2 – 10 (because 10 is closest to zero in the B group).
Any suggestions on how to go about this?