BookmarkSubscribeRSS Feed

SAS Viya 3.4: CAS Views vs. Data Views

Started ‎06-17-2019 by
Modified ‎06-18-2019 by
Views 5,827

I recently posted an article on CAS Computed Columns and, before that, an article on CAS Views. Both of these topics hint at a larger topic in CAS and Viya: Data Abstraction. Basically, data abstraction is when end users are presented with data that isn't exactly what is stored in the underlying data tables.

 

Within the SAS Viya platform, there are two main tools for data abstraction: CAS Views and Visual Analytics Data Views. Both provide mechanisms for creating "virtual tables," structures that are surfaced to the end-user that look and feel like data tables but that don't really exist within CAS.

 

(Obviously complex analyses and reports change the data too but we're concerned here with anything that looks and acts like a database view, a BO Universe, or a SAS Information Map, basically anything that is presented to the end-user as the basis for a report or analysis.)

 

So, let's dive into Viya data abstraction! We'll summarize both CAS Views and VA Data Views, and, in the case of Data Views, the major components they can accommodate, to see how the two compare and when we should use one over the other.

CAS Views

CAS Views are virtual tables that build on another CAS table (or more rarely a SASHDAT file). They are usable in SAS code as well as all of the Viya visual interfaces which treat them just like CAS tables.

 

In Viya 3.4, CAS Views support complex and conditional calculated fields as well as complex filtering. Viya 3.4 CAS Views do not support joins or aggregation however. (There is a major push to add star-schema join capabilities in 3.5.)

 

Capabilities: Complex and conditional calculated columns; Filters

 

Available In: Code; All Viya web applications (VA, VS, VDMML, Decision Manager, ...)

 

Limitations: Lack of join or aggregation support in 3.4

 

Creation Example:

 

proc cas;
 table.view /
    name="virtualMega_corp"
    caslib="DM"
    promote=true
    tables={{name="mega_corp" 
             caslib="visual"
             computedVars={{name="Margin"} {name="RemainingLife"}}
             computedVarsProgram="Margin = Revenue - ExpensesMaterial;
                                  RemainingLife = UnitLifespan - UnitLifespanLimit;"
             where="facilityID = 2"
          }};
 run; 
 quit;

 

For more information on CAS Views, see my previous post as well as the external documentation.

VA Data Views

Visual Analytics Data Views allow for common reporting constructs to be shared among Visual Analytics reports. Some of these constructs are more reporting/analytics related like hierarchies, spline effects, parameters, and interaction effects. While others are more data management related like calculated items (basically CAS computed columns), Custom Categories (basically CAS computed columns or CAS Formats), and Filters (basically WHERE clauses). Regardless, they are all presented from a reporting and analytics context.

 

VA Data views have no connection to CAS Views. Data Views are exclusively a Visual Analytics construct and, as such, Data Views are only accessible inside Visual Analytics itself. They are neither accessible from code nor from other Viya visual interfaces like Decision Manager.

 

Capabilities: Complex and conditional calculated columns; Filters; SQL Joins; Aggregations; Parameters; Custom Categories; Hierarchies; Spline Effects; Interaction Effects; ....

 

Available In: Visual Analytics only

 

Limitations: Visual Analytics only

 

Creation Example:

 

DataViewDataAbstraction-1024x709.png

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

 

For more information on Data Views, see this article.

Key Components Supported by Data Views

While Data Views support a number of reporting/analytics constructs, below we'll dive in more to some of Data Management-like components which compare more to traditional DBMS View capabilities including:

  • Calculated Items
  • Aggregated Data Sources
  • "Data Source Join"
  1. Calculated Items

    While they manifest in generated code as CAS Action computed columns or DATA Step assignment code, Visual Analytics Calculated Items are created inside the VA User Interface. Calculated Items are created within a report definition and only exist within that report. Thus, without the use of VA Data Views, they cannot be shared among other reports. They offer equivalent capabilities as CAS View Computed Columns.

     

    Capabilities: Complex and conditional calculated columns

     

    Available In: Visual Analytics only

     

    Limitations: Visual Analytics only

     

    Creation Example:

     

    CalcItemDataAbstraction-1024x788.png

     

  2. VA Aggregated Data Sources

    Like Calculated Items, Visual Analytics Aggregated Data Sources are created through the Visual Analytics User Interface. As the name would suggest, they are used to pre-aggregate detailed data prior to report execution. Pre-aggregation is useful for combining different levels of aggregation in the same report.

     

    While Data Views are logical constructs, Aggregated Data Sources manifest as global CAS tables. So when an Aggregated Data Source is created, either by itself or as part of a Data View, a new global CAS table is created to house that aggregation. These tables are stored in the report user's CASUSER directory and only exist for the duration of the report creation or report execution exercise however. So they are temporary and thus operate like views. Due to their temporary nature, they are not really usable outside of Visual Analytics. (You could manually identify them in the CASLib and utilize them elsewhere but this would be a hack). So they are usable only inside Visual Analytics and are not usable in either code or by the other Viya user interfaces.

     

    Capabilities: Aggregation

     

    Available In: Visual Analytics only

     

    Limitations: Visual Analytics only; Materialized table paradigm

     

    Creation Example:

     

    AggregatedDataAbstraction-1024x737.png

     

    For more information on Data Source Joins, see this post.

     

  3. "Data Source Join"

    The "Data Source Join" functionality allows the report builder to join-in additional tables as the name would suggest.

     

    It works similarly to Aggregated Data Sources in that the join result is materialized as temporary global CAS table in the report user's CASUSER CASlib. So, as with aggregated data sources, you can't really use these join results in other analyses. Additionally, since join products could be several times larger than the original CAS table, users must be conscience of the size of the join product and account for it in the CAS Disk Cache. Joining could also negatively impact performance if the tables are large and the join process is not optimized.

     

    Capabilities: SQL join multiple tables

     

    Available In: Visual Analytics only

     

    Limitations: Visual Analytics only; Performance and sizing concerns (materialized table paradigm)

     

    Creation Example:

     

    JoinDataAbstraction-2-1024x679.png

     

    For more information on the VA "Data Source Join" functionality, see this post.

Conclusion

In SAS Viya 3.4, Data Views offer considerably more functionality than CAS views. While CAS views really only support computed columns and filtering, Data Views support aggregation and join capabilities, along with computed columns and filtering. However, Data Views suffer from a lack of universality since they are only available to Visual Analytics. Additionally Data Views support aggregation and joining via Visual Analytics components that create temporary materialized tables which can bring sizing, performance, and increased I/O concerns. Finally we are anticipating Star Schema join capabilities and increased robustness in CAS Views with the 3.5 release.

Comments
Version history
Last update:
‎06-18-2019 09:28 AM
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 Labels
Article Tags