BookmarkSubscribeRSS Feed

Creating Hierarchies to use in SAS Visual Analytics Reports

Started ‎12-09-2022 by
Modified ‎05-11-2023 by
Views 1,968

According to Wikipedia, a hierarchy "is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another." In reports, hierarchies are used to group data together and then as you drill "down" into the hierarchy you are presented with more detailed data.

 

I have recorded an accompanying video tutorial for these examples so that you may follow along.

 

One straight forward example is using time. For example, you may start at the Year then drill down into more detail to the Month level, and then drill down into Day. You can also use a geographic example. If the top level is Country then State/Province then City.

 

In SAS Visual Analytics, you can create hierarchies by defining the levels in order from the top or most general level down to the more detailed level. While there are no limitations as to how you structure your hierarchy, be conscience that the typical arraignment is based on parent-child relationships and if your data does not lend itself as such you may get unexpected results.

 

You can create a hierarchy from categorical data items which include date/datetime and geographic items. Not all SAS Visual Analytics report objects support a hierarchy Role assignment or may only support one hierarchy at a time. For additional details please refer to the SAS Documentation: Working with Hierarchies in a Report.

 

Create a Hierarchy: Geography Example

 

To manually create a hierarchy, use the + New data item menu and select Hierarchy.

 

01_NewManualHierarchy.jpg

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

Next, select the data items in the order you want and either double-click on them to move them to the Selected items side or select the data item and use the horizontal arrows.

 

Notice that as you add data items to the hierarchy, the Name is automatically generated for you. If you start typing in the Name field, then the auto-generated name will stop and the custom name will be kept. If you clear the name field and rebuild the hierarchy then the auto-generated name will regenerate.

 

02_BuildManualHierarchy.jpg

 

Now we can add this hierarchy to a report object. Since we built this hierarchy using geography data items, let’s use a Geo bubble map object. Here you can see from the Roles pane we assigned our hierarchy to the Geography role.

 

03_GeoHierarchyInGeoMap.jpg

 

 

To navigate the hierarchy, simply double click on the bubble in the map. You can see the breadcrumb path of the hierarchy in the upper left of the geo map, use those hyperlinks to navigate back to the top of the hierarchy.

 

04_GeoHierarchyClickPath-878x1536.jpg

 

 

 

Create a Hierarchy: Automatic Date/Datetime Example

 

SAS Visual Analytics has really neat features that help automatically generate data items. One of these features is the Quick Calculations, check out this article for additional details: Using Calculated Data Items in SAS Visual Analytics. A second example of an automatic feature is the date/datetime hierarchy.

 

From SAS Documentation, Add a Date Hierarchy to a Report, here are the levels which are automatically generated depending on the format of the source data item, some of the levels might not be created.

 

Date Data Item Datetime Data Item
  • Year
  • Quarter
  • Month
  • Day
  • Year
  • Quarter
  • Month
  • Day
  • Hour
  • Minute
  • Second

 

To create a new automatic date hierarchy, right-click on a date data item and select New date hierarchy. The Date Hierarchy is automatically built for you and you can see it listed in the Data pane. To inspect or alter the levels in the hierarchy, right-click on the hierarchy and select Edit.

 

05_NewAutoDateHierarchy.jpg

 

From this Edit Hierarchy window you can choose to keep all of the levels under the Selected items column or you can remove them.

 

06_AutoDateHierarchy.jpg

 

You may notice that these automatically generated data items are not listed in the Data pane. That is because, by default, these data items are generated but not shown. To see these data items in the Data pane use the overflow menu and select Show or hide data items. Then you can see the automatically generated data items in the Available items column. Move them to the Selected items column if you want to see them listed in the Data pane.

 

07_ShowDataItems-1024x811.jpg

 

I chose to use a Crosstab object so that I can expand all of the levels of the hierarchy for you to see the default formats. To change these formats, you must first use the Show or hide data items window to make the automatically generated data items visible. Then you can use the data properties format menu to select the desired format.

 

08_DateHierarchyInCrosstab.jpg

 

 

Once you use the automatic date hierarchy to generate the date/datetime data items, you can change their formats and make your own custom hierarchies.

 

09_CustomDateHierarchy.jpg

 

Here is an example of using the newly created date hierarchy and using it in a Bar Chart object.

 

10_DateHierarchyInBarChart-1024x830.jpg

 

Create a Hierarchy: Automatic Crosstab Example

 

Another way to create a hierarchy is from the Crosstab object. In this example, I will use standard category data items with parent-child relationships and add them to the Columns Role in a Crosstab.

 

You can see that I added Product Brand, Product Line, and Product. When you right-click anywhere on the column headings, you can select Create and add hierarchy to columns.

 

If you had added these data items to the Rows Role then the menu selection would have said Create and add hierarchy to rows.

 

11_NewAutoCrosstabHierarchy.jpg

 

In this next screenshot, you can see that I right-clicked on the automatically created hierarchy and selected Edit so that you can see the hierarchy details. You can also see how the automatically created hierarchy has been atomically added to the Columns Role.

 

12_AutoCrosstabHierarchy-1536x1031.jpg

 

You can use this automatically generated hierarchy as any other hierarchy in other report objects. In this example I added it to the Tile Role in a Treemap object.

 

13_HierarchyInTreemap-1024x392.jpg


Summary

 

I have shown you three ways to create a hierarchy:

 

  • Manually define the hierarchy levels using the new data item menu.
  • Automatic Date/Datetime hierarchy by right-clicking on a date/datetime data item.
  • Automatic Crosstab hierarchy by adding category data items to either the Column or Rows and right-click in the header area.

 

Hierarchies can be used in many report objects and help keep reports interactive while providing insights at each of the different hierarchy levels. Here is a demonstration of navigating the hierarchies shown in this article.

 

 

 

Check out the below articles for additional SAS Visual Analytics examples:

 

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎05-11-2023 04:49 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags