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
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.
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.
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_
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.
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_
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
For the _TYPE_ values you describe your CLASS statement must have been:
CLASS SCHEDULE REGION ;
The last class variable is used for the least significant bit of the _TYPE_ value. So odd values of _TYPE_ will include REGION as it is last variable listed in the CLASS statement.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.