OK, your explanation makes a big difference. Here's an approach you can take.
data _null_;
infile 'current_program.txt';
file 'revised_program.txt' noprint;
input @;
if _infile_ =: 'IF' then do;
n + 1;
put n z3. ': ' @;
end;
else if _infile_ =: 'ELSEIF' then put n z3. ': ' @;
put _infile_;
run;
The nested ENDIF labels don't quite match up this way, but it may be close enough for readability (or it may give you enough of an idea about how to improve the logic).
Good luck.
... View more