You can do this with Proc REPORT, see example below. It uses a computed column as the last column. From this compute block you can control all the column values left of this column. Within a compute block, you have the _BREAK_ variable, that tells whether you are in a break line and then set the values accordingly. The _dummy column is printed to understand what values you have available. You can set it to NOPRINT to suppress printing, the columns created by the across, need to be accessed by their column number like _Cn_.
SampleCode:
data forReport;
set sashelp.cars;
where make in ("Audi", "Volvo", "Volkswagen");
select (make);
when ("Audi") mediRank = 1;
when ("Volkswagen") mediRank = 2;
when ("Volvo") mediRank = 3;
otherwise;
end;
keep make driveTrain type Horsepower mediRank;
run;
proc report data=forReport;
column mediRank type driveTrain, horsePower _dummy;
define mediRank / group;
define type / group;
define driveTrain / across;
define horsePower / analysis;
define _dummy / computed;
break after mediRank / summarize;
compute _dummy / char length=32;
_dummy = catx(":", mediRank, _break_);
if lowcase(_break_) = "medirank" and mediRank ne 1 then do;
type = "Total";
end;
if lowcase(_break_) = "medirank" and mediRank = 1 then do;
call missing(mediRank, type);
call missing(_c3_, _c4_);
end;
endcomp;
run;
... View more