Find below a new program. This time it checks for a "n" in the name, and uses this condition to sum up the special total values.
You also need an additional grouping variable to create an additional "break" line. the code also sums up age and height.
data newclass;
length sex $ 64;
set sashelp.class;
* needed for special summary line;
sex2 = sex;
run;
proc report data=newclass;
column sex2 sex name age height _dummy;
define sex2 / order /* noprint */;
define sex / order;
define name / order;
define age / analysis sum;
define height / analysis sum format=comma10.1;
define _dummy / computed /* noprint */;
compute _dummy / char length=32;
* declare variable to keep special total;
length ageTotal2 8 heightTotal2 8;
if find(name, "n") > 0 then do;
call define("name", "style", "style={background=bioy}");
call define("age.sum", "style", "style={background=bioy}");
call define("height.sum", "style", "style={background=bioy}");
* use of SUM statement, so values are retained;
ageTotal2 + age.sum;
heightTotal2 + height.sum;
end;
* for illustration only to see whats going on;
_dummy = catx(":", _break_, ageTotal2, heightTotal2);
* detect special total line and fill columns as needed;
if upcase(_break_) = "SEX2" then do;
age.sum = ageTotal2;
height.sum = heightTotal2;
sex = "total for name ? n";
* reset ageTotal2 as we begin a new group;
call missing(ageTotal2, heightTotal2);
end;
endcomp;
break after sex / summarize;
break after sex2 / summarize;
* rbreak after / summarize;
run;
... View more