BookmarkSubscribeRSS Feed

CAS Views!!! Use Cases (Viya 3.3)

Started ‎04-03-2018 by
Modified ‎04-03-2018 by
Views 4,544

From DBMSs to base SAS to Hadoop Hive, views offer powerful functionality and now CAS is in on the act! In Viya 3.3, CAS' View capabilities extend beyond the session level so that certain CAS Views can be used in VA 8.2.

 

Let's illustrate CAS views with two use cases -- a simple one, using CAS views as a semantic layer, and an advanced one, using CAS views to transpose a table.

 

. .

Use Case 1:....Semantic Layer

 

Like SAS Information Maps, views can be used to add end-user "sematics" to data. What are semantics? Think "end-user context." To meet all requirements, you might need to create your CAS data in a less refined format than your end-users are used to seeing it. With views, you can add the context to this "raw" CAS data table after it's loaded.

 

As a simple example, maybe you store all datetimes as GMT/UTC so that transaction times from different parts of the world are all easily comparable. However your executive team in New York wants to see everything in Eastern time. So you build an "Executive" CAS view that transforms the GMT datetimes to Eastern time.

 

Here's a (non-DST compliant) version of what such a view might look like. 

 

 

Simple CAS ViewSimple CAS View

  

For more information on the table.view CAS action, see the documentation.

.

 

Use Case 2:....Transposing Tables

 

In Viya 3.3, CAS Views can go well beyond simple field transformations too. To illustrate the power available, let's effectively transpose a CAS table with a view.

 

Why would we ever do this? Because some VA objects need their tables "long and thin" with generic measure fields whose exact meaning is determined by categorical variables (e.g. waterfall chart) while others need their tables "short and wide" with lots of very specific measure fields (e.g. correlation matrix). With a CAS view that transposes our CAS table, we can satisfy both configurations with the same CAS table saving disk/memory space as well as eliminating the need to maintain and synchronize two versions of the same data. .

 

CAS GL Table

 

For this example, we'll "transpose" a general ledger (GL) CAS table. GL tables are great for reporting/analysis because they usually contain ALL of the transaction data. They are fashioned like normal transaction tables but instead of facilitating a single transaction type (orders, touch points, shipments), they facilitate them all using a GL Account field which functions something like a transaction type.

 

For this example, here is our GL table. Again, it's a transaction table. So each record represents a transaction.

 

 

Sample General Ledger TableSample General Ledger Table 

Transpose it with a CAS View

As is, this table would make a great waterfall chart but the correlation matrix (and other VA/VS objects) require their input CAS table to have the categories of measures strung out as individual columns like this:

.

 Transposed General Ledger TableTransposed General Ledger Table 

To get our GL table from its raw "long and thin" format into this "short and wide" format, we use the table.view CAS action as shown below: .

 

 

WideGL CAS ViewWideGL CAS View

 

 

The view defines the 4 columns shown above (productRevenue, fixedCosts, etc.) as the amount field (amt) times an INDEX function. The function will return either a 1 or a 0 depending on the text in the account name field (accountNm). If the text is "Product Revenue" then the index function in the productRevenue equation is set to 1 and, consequently, the value of productRevenue is set to the amount field (1 * amt). All the other calculated variables are set to 0 because the text does not match (0 * amt). If the text is "Fixed Costs" then the index function in the fixedCosts equation is set to 1 and, consequently, the value of fixedCosts is set to the amount field (1 * amt). Again, all of the other calculated variables are set to 0 because the text does not match. And so on until the entire table is effectively transposed....

 

When viewed through SAS Studio, the resulting CAS view looks like this: 

 

 WideGL CAS View (SAS Studio)WideGL CAS View (SAS Studio)

  

While not as pretty as the perfectly transposed and reduced table above, it works because VA automatically sums the columns. In fact, it is even better because it maintains the proper number of transactions (records). .

 

Report and Analyze in VA

 

Combining the CAS GL table with the CAS wideGL view, we can produce both a waterfall chart as well as a correlation matrix (as well as many other VA/VS objects) from our GL data from only one physical CAS table.

 

 VA Report Combining GL Table and WideGL ViewVA Report Combining GL Table and WideGL View

  

Further Considerations

The two examples above should give you an idea of the syntax as well as some ideas for what CAS views can do. Additionally, here are some notes that should be considered when using CAS views.

 

  • The varlist parameter is required. Without the varlist parameter, CAS Views will not function in VA 8.2.
  • CAS Views can be created on either CAS Tables or the CASLib DataSource. If built on a DataSource, the required data is loaded into CAS at VA/CAS action execution and dropped after the VA/CAS action is finished.
  • The code in the computedVarsProgram is DATA Step
Comments

Which Other BI Server tools objects can we migrate successfully to  SAS Viya can you please provide me details or any work arround for the not supported objects

Version history
Last update:
‎04-03-2018 04:04 PM
Updated by:
Contributors

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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