Hi @SASPhile,
I take it that you derive your current dataset (let's call it HAVE) from another dataset (HAVE0) and compute the page number as shown.
Example:
data have0(drop=i);
do treatment='Z', 'L';
do i=1 to 10;
output;
end;
end;
run;
data have;
set have0;
pg=ceil(_n_/8);
run;
To obtain the improved page numbers you could start with HAVE0 and derive variable PG as follows:
data want(drop=_ctr);
set have0;
by treatment notsorted;
if first.treatment then _ctr=1;
else _ctr+1;
if mod(_ctr,8)=1 then pg+1;
run;