DATA Step, Macro, Functions and more

suppression and secondary suppression in Proc Tabulate

Reply
Regular Learner
Posts: 1

suppression and secondary suppression in Proc Tabulate

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         ---

 

Smiley LOL Please. Thank you.

 

SAS Super FREQ
Posts: 709

Re: suppression and secondary suppression in Proc Tabulate

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

Ask a Question
Discussion stats
  • 1 reply
  • 208 views
  • 1 like
  • 2 in conversation