I think your highest level problem is what @DmitryShopin mentions in his comment. However, my answer may be what is stopping the macro from resolving.
Your %If %Then statement within the %Total macro needs another semi-colon at the end. One semi-colon for the variable assignment statement and one semi-colon for the %If %Then statement. If you are generating more than one variable assignment statement, each one needs an ending semi-colon.
Not sure if this is the only problem without having sample data to test it.