Following up my introductory article about publishing and running a model in-database, I wanted to illustrate this process from different perspectives. The first scenario was about using code. In this second scenario, we will put ourselves in the position of the person who designs models using SAS Viya User Interfaces like SAS Model Studio and SAS Model Manager or designs rule sets/decisions in SAS Intelligent Decisioning.
Before a Data Scientist can easily publish SAS models or decisions in Teradata using SAS Model Studio, SAS Model Manager or SAS Intelligent Decisioning, there is one step that a SAS administrator will have to do first: creating the appropriate Publishing Destination for Teradata.
This is done in SAS Environment Manager => Publishing Destinations.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
It’s a simple step where the administrator will specify a name for the destination, a Teradata CASLIB with write capabilities, and the model table: a table in Teradata that will act as a repository of models (the first time, it will be created in the referenced CASLIB).
This is the part that is done in SAS Model Studio instead of SAS Code (my previous article). I won’t learn you how to do that, there’s a good probability that you know better than me on this topic. Let’s assume we have a pipeline designed in SAS Model Studio and we want to publish the champion model in Teradata.
Here is a very simple pipeline example with 2 models:
If instead of a model, we want to publish a decision (a rule set can also be published) then let’s assume we have an existing decision ready to go.
Here is a very simple decision relying on 3 rule sets:
Now that we have a pipeline in SAS Model Studio, we are now able to publish models in the Teradata publishing destination, created earlier. In the “Pipeline Comparison” tab, you can select a model and click on “Publish models” as shown below:
Then we specify how we want to publish:
If instead of directly publishing from SAS Model Studio, you or your users manage numerous models, you might use SAS Model Manager. Of course, publishing models is also possible from this application:
You get a similar dialog box:
Finally, if you want to run decisions or rule sets in a publishing destination, SAS Intelligent Decisioning also offers you a way to easily publish them:
Decisions can be published in Teradata for example only if they contain objects that are supported for the destination. Rule sets, lookup tables, models from SAS Model Manager, etc. are supported for in-database destinations. Some components like Python code files, data query files or MAS modules are not supported. This is documented here.
This time, you will get asked if you want to add some runtime tracking information to the decision. Then when you run the decision in the database, additional metadata are written to the output table.
So far, we have seen that multiple SAS applications provide a way to publish models or decisions interactively and easily.
When it comes to the execution of the model or decision, the only way to do it is programmatically. So everything mentioned in my previous article (Publish and Run a Model In-Database From Code – A Teradata Example – “Run the model in Teradata” section) will still apply here.
As stated in this previous article, to run a model in Teradata from SAS, we use the SCOREACCEL procedure (and the runmodel statement) or the modelPublishing.runModelExternal CAS action (the SCOREACCEL runmodel statement calls this CAS action behind the scenes):
proc scoreaccel sessref=mysession ; runmodel target=teradata caslib="tera" modelname="mymodel" modeltable="sas_model_table" intable="hmeq_prod" outtable="hmeq_prod_code_scored" outkey="RECORD_PK" ; quit ;
In the modelname property, you specify the name of the model/rule set/decision that you want to run in Teradata.
In this article, we have illustrated how a SAS user can design a model or decision and publish it in Teradata from a user interface perspective.
I also have a YouTube on this topic:
Thanks for reading.
Find more articles from SAS Global Enablement and Learning here.
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.