Manually modify lists for survival analysis

Let's take

list = {{1, 1, 1, 0, 1, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1}, {0, 1, 1, 1}, {0, 0}}

and run

list /. {x : 1 ___, z : 0 ___, y___} :> PadRight[{x}, Length@{x, z, y}]

{{1, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0}}


Original answer:

Cases[list, {x : 1 ___, 0, y___} :> PadRight[{x}, Length @ {x, 0, y}]]

{{1, 1, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0}}

Equivalents:

Cases[list, {x : 1 ___, 0, y___} :> Flatten @ {x, 0, ConstantArray[0, Length @ {y}]}]

Cases[list, {x : 1 ___, 0, y___} :> Join @@ {{x}, {0}, ConstantArray[0, Length @ {y}]}]

Fails when a list is composed only of 1s.

UPDATE:

This is a fix:

Cases[list, {Longest[x : 0 .. | 1 ..], y___} :> PadRight[{x}, Length @ {x, y}]]

Edit

As kglr points out in a comment:

FoldList[Times]/@list

Original Answer

FoldList[Times, #] & /@ list 

{{1, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0}}