turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- In summary procedure if we have more than 2 variab...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-08-2014 06:44 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to chittamsri1_gmail_com

04-08-2014 07:07 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to chittamsri1_gmail_com

04-08-2014 10:06 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

04-08-2014 11:26 AM

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

_type_

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

04-08-2014 11:39 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

04-08-2014 12:11 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

04-08-2014 09:27 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to chittamsri1_gmail_com

04-08-2014 11:46 AM

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.