I don't have the prettiest solution but it gets the job done without too much high level coding.  One note your dates include impossiblities like 31-Feb which doesn't exist.  See the below code:
By ordering the data and using SAS's first./last. and the retain statement you can build rolling statistis within groups.
proc sql;
  create table one 
  (name char(1)
   ,period char(8) 
   ,ret num);
 insert into one
  values('A', '20010131', 0.1)
  values('A', '20011231', 0.12)
  values('A', '20020228', 0.22)
  values('A', '20021231', -0.33)
  values('B', '20010131', 0.12)
  values('B', '20011231', 0.15)
  values('B', '20020228', 0.44)
  values('B', '20021231', -0.06)
  ;
 create table two as
   select name, put(input(period,yymmdd10.),year4.) as year ,input(period,yymmdd10.) as period format=yymmdd10., ret
   from one
   order by 1,2;
quit;
data three;
  set two;
  by name year;
  retain sum_product NO 0;
  if first.year then do;
    sum_product=1;
	NO=0;
  end;
  NO+1;
  sum_product=sum_product*ret;
  
  if last.year;
run;