BookmarkSubscribeRSS Feed

Creating Hierarchies to use in SAS Visual Analytics Reports

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

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.



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.




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.





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.






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.




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




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.




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.





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.




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




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.




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.




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.





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:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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