This article presents another example of a use case that applies the technique you have learned to integrate SAS Visual Analytics (VA), Data-Driven Content (DDC) objects, and SAS jobs. As always, it builds on top of assets and examples discussed previously, in other articles of this series.
In this use case you want to eliminate outliers from your time series chart, so that spikes that might occur in the last period of time, due to incomplete data for that period or other factors, will not penalize the visualization because of changes in the Y axis scale that occurred to accommodate the spikes.
As you can see in the screenshot, if it were not for the spikes at the end of the time series in two of the products, the data points in this chart would not be squeezed at the bottom of the chart, and the visualization would be much better.
Time Series Outliers Example
The data used in this example was fabricated by transforming the table PRDSALE from the SASHELP library and provided to you as a SAS dataset named OUTLIER in GitHub. It contains KPI information for five different products on a monthly basis.
The goal is to use a SAS job to detect the outliers and remove them. The rules used for defining outliers and what “remove them” really means can vary, but you will keep them very simple in this example:
The time series is grouped by product, so the analysis must be performed individually for each product and the rule should only be applied for the last month in each series.
Data-Driven Content Code
The DDC used in this example will be the same one presented in previous article, without any changes. Enough enhancements were made to that DDC to make it reusable and you will be just leveraging it here. The name of the DDC is ProxyDDCForVAJobCASIntegration.
SAS Job Code
As happened with the previous use case, the job code used in HelloCASWorld example is a good starting point for implementing this solution. You will only need to add the highlighted code in the “Main Processing” block:
SAS Visual Analytics Report
The report was also kept simple. The time series chart at the top displays the data coming from the original data source called OUTLIER, which was loaded in memory in the Public CAS library. The time series at the bottom contains the improved visualization, based on the table created on the fly by the SAS job. This table was named OUTLIER_CLEAN. The DDC object is in the blank space at the top right of the report. The three data items applied in the time series Roles tab were also applied to the DDC: Month, Product, KPI. The slider control object has a filter action to the DDC and the first time series.
Whenever you modify the selection in the slider, the DDC receives new data, and responds by executing the job, which in turn loads in memory a new table OUTLIER_CLEAN without the outliers. The time series chart at the bottom has automatic refresh turned on, so at the specified interval it reads the new data and displays the results.
When designing a report like that from the scratch you must remember of a few things discussed in the previous articles, such as:
If you have the right privileges for exporting and importing content in SAS Environment Manager (menu option Manage Environment), you can replace all the steps above by exporting the report and them reimporting it. You just need to replace the target CASUSER(<userid>) library with just CASUSER in the GUI during the import process.
_job_output_cas_table: "OUTLIER_CLEAN"
_job_executing_message: "Removing outliers..."
_job_name: "/Public/Jobs/SAS Communities/Outlier”
Deploying This Example
All files and data used in this example are available for downloading from the GitHub project sas-visualanalytics-thirdpartyvisualizations, under folder called samples/IntegrationWithSASJobs.
It requires the dataset OUTLIERS that was provided to you via GitHub loaded in memory in the Public CAS library.
Deployment steps:
Note: (1) Starting with release 2023.06, the examples that used to inherit jQuery from their parent (the SAS Visual Analytics web application) no longer work, so we have provided replacement codes. These replacement files have the same names as their original, but they end with .v4. Because of that, some references to line numbers may not exactly match on those .v4 files.
We could have exported all the content as a package, but this would require special privileges in order to import it. Sharing the example as standalone files will give you the opportunity to better explore the SAS Job Execution Web application, familiarize yourself with the content, and understand how they are connected.
Note: The first time a user opens this report it fails because the CASUSER table doesn’t exist yet. Reopening the report will work, as well as any subsequent access to the report. This will happen to any other report that depends on a table that is being dynamically loaded in memory when the report opens.
Next Steps
This is the last article planned for this series. I’ve learned a lot while working on the examples used here, and I refer to them very often whenever I need a template for a new use case. I hope you have found them useful and I hope they can be used as a foundation for your needs as well. As this is an evolving area, I expect to be back soon with a different approach to share with you. Meanwhile, I recommend exploring the references below to learn more about Data-Driven Content and SAS Jobs.
References
Learn More…
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.