Any ways to do suppression and secondary suppression in Proc Tabulate?
My Proc Tabulate Table (example) :
Household size
1 2 3
Mean of Housing Expenditure 5,000 7,000 11,000
Number of Household (weight) 1 500 9 800 7 400
Actually, the sample count for Household size =1 is 25 , Household size =2 is 152 and Household size =3 is 75.
Suppresion rule is that if sample count less than 30, then all the rows (mean and no) of that column should be suppressed.
--> Any method to do it in SAS just like the below table?
Household size
1 2 3
Mean of Housing Expenditure --- 7,000 11,000
Number of Household (weight) --- 9 800 7 400
Moreover, can i also do the secondary suppression in SAS ? That means the second low sample count is Household size=3,
so the first and thrid column are all suppressed.
Household size
1 2 3
Mean of Housing Expenditure --- 7,000 ---
Number of Household (weight) --- 9 800 ---
Please. Thank you.
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.