BookmarkSubscribeRSS Feed

SAS Viya Jobs in a SAS Visual Analytics report

Started ‎05-05-2021 by
Modified ‎05-05-2021 by
Views 9,029

If you are unfamiliar with Jobs in SAS Viya then check out Gerry Nelson’s article: Jobs: Stored processes in Viya.

 

Essentially it’s the new way to submit code to be processed by one of SAS’ analytic engines. There many use cases that can be solved using Viya Jobs, here are a few articles that cover a variety of examples:

This article will cover the three ways you can include a Job in a SAS Visual Analytics report: Job Content object, Web Content object or Data-Driven Content object.

Example Viya Job Used

The Viya Job I will be using for this article is a vanilla flavored, no frills job. This means that this job isn’t surfacing any fancy custom web application code or model scoring in the background.

 

The example job makes use of the SASHELP.CARS data source and uses XML to build the Task prompts. There are two prompts: one for Make and one for Type and the results are streamed using the _output_type of ods_html5.

 

Could the below behavior be modified for a more seamless integration of the Viya Job, absolutely. Take a look at the examples listed at the top or bottom of this article for more in-depth examples.

Job Content Object

Introduced in the April stable release of SAS Viya (2020.1.5) is the Job Content object that will display the output from SAS Viya Jobs.

 

Adding the object to the report canvas and navigating to your desired Job is straight forward.

 

Use the Object pane and add the Job content object to the report.

 

01_JobContentObject.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.

 

Next, use either the Select a job. button from the object or the Browse button from the Options pane to navigate to the desired Viya Job.

 

02_SelectAJob.png

 

In this example, the Viya Job has default values assigned to the two prompts which are used for the initial execution. The results are displayed in SAS VA report in the Job content object.

 

03_Results.png

 

Use the object’s overflow menu and select Set job parameters… to bring up the dialogue to select different prompt values. When you click Close the job is executed.

 

04_SelectPromptValues.png

 

Configuration tip: To ensure the best performance, adjust the minimum number of SAS Compute servers available to your environment. This will save time so that when the SAS VA report is opened and the Viya Job needs to execute, time is not spent waiting for a SAS Compute server to be spun up. See the SAS Viya Administration Documentation under Configure a Pool of Available Servers.

Web Content Object

The second way you can show results of a Viya Job in a SAS VA report is using the Web content object.

 

05_WebContentObject.png

 

Once the object is added to the VA report, use the Options pane and replace the default URL value with your SAS Viya Job URL.

 

06_JobURL.png

 

You can get the Viya Job URL from SAS Studio’s Properties pane.

 

07_GetJobURL-1024x591.png

 

You can see that using the Web content object displays the Job’s prompt form in the VA report window. After you make your selections, the default values are pre-populated here, the results open in a new browser window.

 

08_SelectPromptValues-1024x697.png

 

09_Results-1024x378.png

 

If you see this error: Popups must be enabled

 

10_PopupError.png

 

Then follow the instructions for adding the allow-popups to the sas.visualanalytics IFrame Sandbox Attribute Value property as described under the SAS Visual Analytics Documentation: Configuration Properties for SAS Visual Analytics. This note is also mentioned under the Working with Job Content.

 

11_SASEVConfig-1024x609.png

 

Remember you could code a more custom web application that surfaces an HTML form with both the prompts and Job results in the same window. For more examples, take a look at Mike's articles mentioned earlier:

Data-Driven Content Object

For this object, when using a "typical" Viya Job, it behaves like the Web Content object. That is once you define the URL Option property the results will open in a new tab.

 

12_DDCObject.png

 

The one main difference is that the Data-driven content object requires a Role assignment.

 

13_JobURL-1024x498.png

 

14_Results-1024x397.png

 

The true power behind the Data-driven content object is that you can essentially surface a custom web application and as many of our dedicated coders know, this can be achieved through a Viya Job. Take a look at some of Xavier’s articles mentioned earlier for integrating both Viya Jobs and the Data-driven content object.

  • Xavier Bizoux’s: Data Entry in SAS Visual Analytics 8.1 Series: Part 1 | Part 2 | Part 3 | YouTube
  • Xavier Bizoux’s: VA Report Example: Geographic data, SAS Viya Jobs, Data Driven Content, and REST APIs! Article | YouTube

Summary

Let’s outline the important takeaways for our options for executing Viya Jobs in a SAS VA report:

  • Job content object
    • Job results are displayed inside the SAS VA report, not in a separate browser tab
    • You must use the object’s overflow menu to open the prompt window to select different prompt values
  • Web content object
    • Prompt window is displayed inside the SAS VA report
    • Using default configuration, job results are displayed in a separate browser tab
    • Able to customize Viya Job code to be rendered as an HTML page with the ability to surface both prompts and results inside the SAS VA report.
  • Data-driven content object
    • Using default configuration, the prompt window is displayed inside the SAS VA report
    • Using default configuration, the job results are displayed in a separate browser tab
    • Able to customize Viya Job code to be rendered as an HTML page with the ability to surface both prompts and results inside the SAS VA report.

Regardless of the object you use to display the results of your Viya Job, be sure to get the most from your environment by making sure these configurations are set:

 

 

Comments

I love the possibilities that arise from using viya jobs.I use them to score new data or to transpose the data.

And I'm wondering if I can display back to the report a graph generated via job and proc sgplot.

I know how to pass the data with DDC and use json to write it to a table and run proc sgplot.

But how can I achieve that the graph displays inside the ddc object itself?

Hi,

Based on my understanding of your question, you have a web page that is displayed in the DDC object. You are passing data to the web page and the data are then used to call a Viya Job. The step you are missing is how-to display the generated image in the web page without overwriting the actual web page with an html output streamed from the job. 

If my understanding is correct, I think the following example will help you in the process of retrieving an image generated by a SAS Viya Job: 

https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/jobexecug/n0t91q5lsc2b8qn14fd0cgbmylr8.htm...

In the example, you will see how you can generate multiple output files using a job. The biggest difference with the example is the way you will return the reference to your image. The reference should be returned as a JSON object. This way you will be able to further process the image in the web page displayed in the DDC object. 

Let me know if you need more information. 

Regards, 

x@b

 

 

Hey @XavierBizoux ,

when I go into VA, and look under Objects/content I do not see the Job Content option. We have SAS viya V.03.05M0P111119, is this option not available in this release?

jimbobob_0-1637367334901.png

 

@jimbobob  - Looks like you are using Viya 3.5. The functionality in the article was introduced in Viya 4 aka Viya 2020.1.5.

Hi @jimbobob

The Job content object is only available as from Viya 2020.1.5 stable release.

https://go.documentation.sas.com/doc/en/vacdc/v_003/vawn/n0m7pkbnv19v09n1sazgnamqk6qv.htm

In Viya 3.5, the best option is to use the Data-Driven Content object. It will add some extra functionalities compared to Web Content object.

Regards,

Xavier

I always like reading your article. Is there an OOTB dynamic interaction between VA report objects and objects created by SAS Job Execution? I saw a couple of blogs and videos from Xavier, and he is using javascript for the magic.

Hi @pritesh_sas , 

Thank you for the positive comment. 

There is no interaction out-of-the-box between VA report object and SAS Job Execution object. The only option is to use a Data-Driven Content object and to build a custom web page to handle the parameters collection and the job execution. The logic will be to pass data from the VA report to the DDC object for example when you select a row in a list table. Then the web page used for the DDC object will manipulate the data and send the request to the Job Execution which will execute and return the result. You have different options to launch the job, you trigger the job execution as soon as the data selection changes without user interaction in the DDC object. Or you populate a form in the DDC object and the user needs to trigger the execution by clicking on a submit button for example. 

I hope this helps you. 

If you have questions, please don't hesitate to contact me. 

Regards, 

Xavier 

Version history
Last update:
‎05-05-2021 01:26 PM
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 Tags