SAS Visual Analytics (VA) empowers users to create interactive reports and dashboards. One of its most powerful features is the Data-Driven Content (DDC) object,
which allows embedding external web applications that respond dynamically to data selections within the report. This opens the door to integrating custom applications built with frameworks like Django, enabling tailored visualizations, advanced interactivity, and external system integrations.
A Data-Driven Content (DDC) object in SAS Visual Analytics is a powerful feature that allows you to embed external web content—such as custom visualizations, interactive dashboards, or applications—directly into a SAS report. What makes it "data-driven" is its ability to send data from the report to the embedded content, enabling dynamic and context-aware interactions.
Integrating Django with the Data-Driven Content (DDC) object in SAS Visual Analytics enables organizations to extend the capabilities of their reports with custom, interactive web applications. The DDC object allows SAS VA to send selected report data to an external web service, which Django can receive, process, and use to render dynamic content inside the report.
This combination is particularly valuable because Django offers full flexibility to build tailored user interfaces, advanced visualizations, and logic-driven responses that go beyond SAS VA’s native features. For example, Django can display custom charts, run machine learning models, or connect to external APIs—all based on the data selected in the SAS report.
Using Django also opens access to the broader Python ecosystem, allowing integration of libraries for data science, visualization, and automation. Developers can build applications that respond in real time to user interactions in SAS VA, creating a seamless and intelligent user experience.
Moreover, Django’s modular architecture and built-in security features make it ideal for enterprise environments. It supports rapid development, easy deployment, and robust access control, ensuring that custom content is both scalable and secure.
In summary, combining Django with SAS VA’s DDC object empowers users to create highly interactive, data-driven applications that enhance decision-making, improve user engagement, and integrate seamlessly with existing analytics workflows.
This demo showcases how a Django web application can be embedded into a SAS Visual Analytics (VA) report using the Data-Driven Content (DDC) object to predict the MSRP (Manufacturer’s Suggested Retail Price) of cars based on selected attributes from the Cars data table.
This demo illustrates how combining Django, sasctl, and SAS VA’s DDC object enables powerful, interactive analytics experiences that bridge data science and business intelligence.
My objective is not to explain how to work with Django. If you want a basic introduction to Django and how to use it in Visual Studio Code, you can refer to Django Tutorial in Visual Studio Code.
The code of the application is available on xavierBizoux/va_django_integration GitHub repository.
Here are some explanations about the application.
This form contains the required components to interact with the VA Data-Driven Content object. It contains the logic to handle the data reception, the check for incomplete data and the submission of the data for scoring.
The sendMessage and the onMessage functions are directly inspired by SAS Help Center: Programming Considerations for Data-Driven Visualizations.
As you may notice in the code, we are receiving data from Django context:
const varInfo = {{ var_info | safe}}
This simple line of code passes some metadata to the JavaScript to handle:
The information received comes from the /va_django_integration/data_driven_content/constants.py
The sample application manages a single scoring form and a single deployed model, but the code structure and the constants file can handle multiple applications/modules. Depending on the parameter you pass in the URL, the application will select what to display and which model needs to be executed:
https://localhost:3000/data-driven-content?app_name=cars-price-estimation
While the scoringForm.html is the template used to generate the UI, the actual logic is handled by the /va_django_integration/data_driven_content/views.py.
This utility file makes use of the sasctl package to score the data stored into MAS. For more information about sasctl package, please refer to sasctl — sasctl 1.11.5 documentation
def score_data(data, module_name):
with Session(SERVER, USERNAME, PASSWORD, verify_ssl=CERTIFICATE) as session:
result = mas.execute_module_step(module_name, "score", **data)
return result
As you can see, sasctl hides the complexity of making a connection to MAS, to make the request to score the data and to return a JSON object with the results.
In this case, we are using SERVER, USERNAME, PASSWORD and CERTIFICATE variables to store the connection. The same credentials will be used for every request. The objective is to demonstrate that while the application connects to the same Viya environment for VA and MAS, other environments can also be used or you can even use third-party products to score data. You could, for example execute any python model that is not even deployed to SAS Viya. It makes the score_data function agnostic!
Integrating Django with SAS Visual Analytics via the Data-Driven Content object unlocks powerful customization capabilities. Whether you're visualizing complex data, embedding machine learning models, or connecting to external APIs, Django provides the flexibility to extend SAS VA beyond its native capabilities.
Django can easily be extended using multiple applications to serve different business purposes. It can also easily be deployed using containers and then integrated in your environment. Using Django, you can benefit from the python knowledge available in your company to build web applications. Notice that depending on your environment and how you deploy the application, you may need to configure SAS Visual Analytics for CORS and CSRF (Configure Cross-Origin Resource Sharing for SAS Viya for REST API’s an... - SAS Support Communities)
For more information about Data-Driven Content and how it can be used to extend SAS Visual Analytics capabilities, please refer to:
Interact with an image to get data!
VA Report Example: Geographic data, SAS Viya Jobs, Data Driven Content, and REST APIs!
Enhance VA reports with dynamic infographics
Data Entry in SAS Visual Analytics 8.3
Find more articles from SAS Global Enablement and Learning here.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.