If you would like to do it in data step. data have;
length month $3 ;
infile datalines delimiter=',';
input permno year month $ pcent ;
datalines;
10104,2008,Jan,+5
10104,2008,Feb,-7
10104,2008,Mar,+2
10104,2008,Apr,+3
10104,2009,Jan,-2
10104,2009,Feb,+5
;
run;
data want ;
set have;
by permno year;
retain cum 1;
if not missing(pcent) then cum=cum*(1+pcent*0.01);
if last.year then do; output;cum=1;end;
run;
Xia Keshan
... View more