Please note in the posted suggestion, there is no initial value in the counters. They should be set to zero before being used as accumulators. As is, invalid totals may result or an abend may occur.
I am also not sure about the requirement that adds 1 when the "value" is a 1 and adds 2 when the "value" is a 2 and so on. I believe that the suggested code (which is not the same as the request) is what is needed.