I recently spent a bunch of time trying to restructure an SPSS dataset that had a sub-optimal structure. After failures with excel macros and SPSS syntax, I ended up with about 100 lines of python using pandas columnar multindex and stack(). The stack/Unstack is so fantastic for preparing data for tableau I recommend everyone learn to use it.