You need to prepare your data upfront, meaning only the dat that should be displayed will be used by Proc TABULATE. For Proc TABULATE to display class values which are not in the data one can use the CLASSDATA= option of Proc TABULATE.
Here is some sample code showing this technique, have a look
*
* create some fake data
*;
data have;
houseHoldSize = 1;
do i = 1 to 25;
houseExpenditure = rand("Normal", 5000, 90);
nHouses = 1;
output;
end;
houseHoldSize = 2;
do i = 1 to 152;
houseExpenditure = rand("Normal", 7000, 90);
nHouses = 1;
output;
end;
houseHoldSize = 3;
do i = 1 to 75;
houseExpenditure = rand("Normal", 11000, 90);
nHouses = 1;
output;
end;
run;
*
* select data according to sample count
*;
%let sampleCount = 75;
proc sql;
create table have2 as
select
*
from
have
where
houseHoldSize in (
select
houseHoldSize
from
have
group by
houseHoldSize
having
count(*) > &sampleCount
)
;
quit;
*
* create a data set with all possible houseHoldSizes
*;
data houseHoldSize;
do houseHoldSize = 1 to 3;
output;
end;
run;
*
* the CLASSDATA ensures that class values without data are still displayed
*;
proc tabulate
data=have2
classdata=houseHoldSize
format=nlnum12.
;
class houseHoldSize ;
var houseExpenditure nHouses;
table
houseExpenditure * mean=" "
nHouses * sum=" "
,
houseHoldSize
/ misstext="---" printmiss
;
run;
Bruno
... View more