Here is an example of building an example data set with some random values.
One variable is coded 1/0 to demonstrate how to get nice single summaries.
data junk;
do cat = 'XXX','YYY';
do subcat='A','B','C';
/* generate random number of values of each cat value*/
do i=1 to (rand('integer',15,60));
/* generate some random 1 and 0 values*/
x= rand('bernoulli',0.3);
output;
end;
end;
end;
run;
proc tabulate data=junk;
class cat subcat;
var x;
table cat all='Total',
x *(n='Number nonmissing' sum='Number of 1'*f=best5. mean='% of 1'*f=percent8.1)
;
table cat *(subcat all='Cat Total') all='Overall Total',
x *(n='Number nonmissing' sum='Number of 1'*f=best5. mean='% of 1'*f=percent8.1)
;
run;
The 0.3 in the call to Rand('Bernoulli', 0.3) means that with enough values generated about 0.3 or 30 percent will have a value of 1, the remainder will have 0.
The Rand('integer') used that way returns value between 15 and 60 as integers with uniform distribution(equal probability of any of the values.
This is simple enough that you should be able to eyeball the N and Sum values and verify that the Mean (as percent) has the correct percent for the Subcat.
... View more