Looking for appropriate loop

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

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 ...
... 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?

Last edited: