Here is a code to create the arrays you need.
I leave it to you to add the computation.
Data is assumed to be sorted by subject;
data computed;
set have;
by subject;
retain ndisp1-ndisp4 pil1-pil4;
array nd {4} ndisp1-ndisp4;
array pl {4} pil1-pil4;
if first.subject then do i=1 to 4; /* clear arrays */
nd(i)=.; pl(i)=.;
end;
/* do for every observation per subject = save data in the arrays */
i = input(substr(week,1,1),1.); /* week nomber 1 to 4 */
nd(i) = numdisp;
pl(i) = pilre;
if last.subject then do;
/* compute the CDOSE by formula */ ......
output;
end; keep subject cdose;
run;
You may need to merge HAVE and COMPUTED tables by SUBJECT to have CDOSE variable on each observation.
... View more