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.
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.
For more information on the table.view CAS action, see the documentation.
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. .
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.
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:
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: .
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:
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). .
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.
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.
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.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.