## In summary procedure if we have more than 2 variables how we will get '_type_' in output

Occasional Contributor
Posts: 12

# In summary procedure if we have more than 2 variables how we will get '_type_' in output

In summary procedure if we have more than 2 variables how we will get '_type_' in output

in the below example we have two variables 'region & schedule'

_type_ = 0  - grand total or overall analysis with out use of two variables (region & schedule)

_type_=1  - analysis is done by using region and with out use of schedule

_type_=2 -  analysis is done by using schedule and with out use of region

_type_=3  -  analysis is done by using schedule and region

Obs  REGION schedule _TYPE_ _FREQ_ Mean Sum Median

1 0 5645 5504.87 31003426 4731.0

2 E1L 1 452 4620.81 2088608 4209.5

3 WESTERN 2 4955 5368.26 26529952 4633.0

4 SOUTHERN E1 3 556 6781.49 3770511 6175.0

Posts: 3,852

## Re: In summary procedure if we have more than 2 variables how we will get '_type_' in output

With three CLASS variable the value of _TYPE_ will range from 0 to 7.  000,001,010,011,100,101,110,111

I think it is easier to understand and use _TYPE_ is you use the PROC SUMMARY statement option CHARTYPE.  Then _TYPE_ becomes a character variable with length equal to the number of CLASS variables where each byte is 0 or 1.  The ith CLASS variable corresponding to the ith byte of _TYPE_.  When the ith byte is 1 the observation includes the ith CLASS variable, when 0 no.

Super User
Posts: 23,791

## Re: In summary procedure if we have more than 2 variables how we will get '_type_' in output

I'm not sure how it decides which is type 1 and then type 2.

However, you can control the levels you get with the WAYS statement.

Posts: 3,852

## Re: In summary procedure if we have more than 2 variables how we will get '_type_' in output

The order of the variables in the CLASS statement(s) determines the order of the bits in a numeric _TYPE_ or byte in a character _TYPE_

CLASS   A B C;
_type_
0       0 0 0
1       0 0 1
2       0 1 0
3       0 1 1
4       1 0 0
5       1 0 1
6       1 1 0
7       1 1 1
Super User
Posts: 13,584

## Re: In summary procedure if we have more than 2 variables how we will get '_type_' in output

Look at the order of your class variables. That determines how the _type_ combinations are set.

You get first, _type_ =0 for all data, then depending on the number of class variables, the summary of each class variable only, then the pairs, then the three-at-a-time, then four-at-a-time... to the combinations of all class variables.

Posts: 3,852

## Re: In summary procedure if we have more than 2 variables how we will get '_type_' in output

```ballardw wrote:

Look at the order of your class variables. That determines how the _type_ combinations are set.
You get first, _type_ =0 for all data, then depending on the number of class variables, the summary of each class variable only, then the pairs, then the three-at-a-time, then four-at-a-time... to the combinations of all class variables.
```

_TYPE_ does not order by _WAY_

_type_ _way_
0000     0
0001     1
0010     1
0011     2
0100     1
0101     2
0110     2
0111     3
1000     1
1001     2
1010     2
1011     3
1100     2
1101     3
1110     3
1111     4
Super Contributor
Posts: 644

## Re: In summary procedure if we have more than 2 variables how we will get '_type_' in output

Another option is to use the TYPES statement which allows specification of subtotals by required combinations of class variables without having to specify values of _TYPE_.

Base SAS(R) 9.2 Procedures Guide

Richard

Super User
Posts: 8,129