@smurray Below one way how to go for processing by group.
data have;
do group=1 to 3;
do x=1 to 5;
/* y=x+1+group;*/
y=x+2;
output;
if group=2 and x=3 then leave;
end;
end;
stop;
run;
/* get max number of rows in a group to define required array elements */
proc sql noprint;
select max(cnt) into :max_grp trimmed
from
(
select count(*) as cnt
from have
group by group
)
;
quit;
%put &=max_grp;
data want(keep=group x y result step_:);
if 0 then set have;
length result 8;
array vx_ {&max_grp} 8;
array vy_ {&max_grp} 8;
array step_ {&max_grp} 8;
do while(not last);
set have end=last;
by group;
_stop+1;
vx_[_stop]=x;
vy_[_stop]=y;
if last.group then
do;
do _i=1 to _stop;
_sX=1;
_startY+1;
call missing(result, of step_[*]);
do _sy=_startY to dim(vy_);
step_[_sx]=vx_[_sx]*vy_[_sy];
_sX+1;
end;
x=vx_{_i};
y=vy_{_i};
result=sum(of step_[*]);
output;
end;
call missing(of _all_);
end;
end;
stop;
run;
proc print data=want;
run;
... View more