Sorry I have updated my example data matrix and the updated my complete code which is causing me problems as I don't know how to update the hash outside the for loop over columns as I want to sum over rows, not columns.
Any additional help will be greatly appreciated.