I am building a SAS DI-studio job to update an analytical base table, as well as draw sample data for building predictive models. As part of the flow, I want to run some python code to do a an SGD classifier based on a term frequency–inverse document frequency of some words. The result of this classifier will be a list of words and weights that will produce features to be used in a SAS miner model.
As far as I can tell, I have the following options:
Are there more options? What would you reccomend?
I don't have any hands on experience of this, just giving my architectural PoV.
If this Python stuff can be seen as part of ETL, I'm pro of having that logic inside DIS.
I don't know which is the best method, but there seem to be an option to call Python from a data step Java object. See the link for details.
Perhaps you could create a custom transformation to package this?
https://github.com/sassoftware/enlighten-integration
I've certainly done this in the past using the xcmd route.
Essentially you're treating the script as any other OS command. Just need to make sure that the account you run your SAS batch processes as is properly setup to execute the python, e.g. has python in it's path, has permissions to run it, and whatever rights it needs to any files/directories.
Top tip - get the python (or bash, cmd, powershell or whatever) script to echo something to standard out when it finished, like some success or fail or whatever text/messages, and use a pipe to read that, so that your SAS process knows that it's worked, or not. You can't always rely on return codes, or the fact that the thing you called actually ran, to know if it worked or not. Experience with flaky Windows servers has lead me to always try to do this.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.