This can also be a solution. However, you have to rewrite it for every different x and Variable 1 value.
if (x="P1" and SYSMIS(Variable1)) Variable1=45.
If there is only one not-missing value for each participant than eli-k's answer is perfect.