data have;
infile cards expandtabs truncover;
input monthID CODE AMOUNT;
cards;
1 105 10000
2 105 9500
5 105 8000
50 202 4000
52 202 3000
57 202 1500
42 203 20000
43 203 19000
;
run;
data want;
merge have have(keep=monthid code rename=(monthid=month code=_code) firstobs=2);
output;
if code=_code then do;
do i=monthid+1 to month-1;
monthid=i; amount=0;output;
end;
end;
drop month i _code;
run;
... View more