BookmarkSubscribeRSS Feed
waiwai
Calcite | Level 5

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.

 

1 REPLY 1
BrunoMueller
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 792 views
  • 1 like
  • 2 in conversation