Hi
I have made good experience with using the CLASSDATA= option in Proc TABULATE. It allows you to specify an order as you need it for your class variable values. See the example below.
/*
* sample data
*/
data carsSubset;
set sashelp.cars;
where make in (
"Volkswagen", "Audi", "Volvo"
, "Toyota", "Honda", "Subaru"
, "Chrysler", "Ford", "Pontiac"
);
random = ceil( ranuni(1234) * 500 );
keep origin type make model driveTrain invoice horsePower mpg_: random;
run;
/*
* sort data in some random order
*/
proc sort data=carsSubset;
by random;
run;
/*
* create structure data, in the sequence as you would like to see them in the report
* all CLASS variables must be present, but not all values
*/
data carsClassData;
infile cards dsd dlm=",";
input
make : $13.
driveTrain : $5.
;
cards;
Toyota,Front
Toyota,All
Toyota,Rear
;
title "1) carsClassData";
proc print data=carsClassData;
run;
title "2) Applied to tabulate";
proc tabulate
data=work.carssubset
classdata=carsClassData
/* only use the class values present in the CLASSDATA= */
/* exclusive*/
order=data
format=nlnum12.
;
class make / order=data ;
class DriveTrain / order=data ;
var invoice;
table
make
, driveTrain * invoice*(n min max mean)
;
run;
title;
Bruno
... View more