Try using the Rangesum() function with Peek(). Be aware of the apostrophes (') in peek and the Order of the table row is important!
Load
rangesum(Flag,peek('Rangesum_script')) as Rangesum_script,
*;
Load * Inline [
Row PNR Flag Rangesum
1 2222 0 0
2 2222 1 1
3 2222 0 1
4 2222 0 1
5 2222 1 2
6 2222 1 3
7 2222 0 3
8 2222 1 4
] (delimiter is '\t');