Looking for appropriate loop

#1
Hi! Hello!
I am looking for solution which lead me from yellow to green results like that:

1565186582896.png
As you can see, there are 0-1 coding data with sysmis, always five 1 per line. Thre are 20 variables (p1,p2, ..., p20) and I need to recode them into 5, using number of columns. I have started with recodig 1-values ...
1565186939124.png
... and I can replace sysmis but I found it difficult to build some loops to make next step. It is necessary to create SPSS script to do that.
Do you have any idea to make it in easy way?

Thanks!
 
Last edited: