Thanks to RAbraham and E Boadi I was able to put together some code
which accomplishes my task.
I realized after their posts that I needed to incorporate one more
condition (case=1) to accomplish exactly what I needed.
I also realized that I didn't have to perform any tranformation on var12
if var12, var17 and var21 were all system missing.
So here is the admittedly inelegant (but effective) solution I cobbled
together with the assistance of the parties mentioned above:
if (class=1 & (sysmis(var12))) & not(sysmis(var17)) var12=0.
if (class=1 & (sysmis(var12))) & not(sysmis(var21)) var12=0.