sas and python, sitting in a tree · sas have been busy in providing python wrappers and interfaces...
TRANSCRIPT
SAS and Python, Sitting in a TreeCameron Lawson (Selerity)
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Who Am I? SAS Consultant with Selerity, a silver SAS and AWS Partner.
Specialists in cloud based SAS delivery.
Close to 20yrs SAS programming, design and delivery experience.
Previously with Origin Energy and various Technology companies.
https://seleritysas.com
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
About Python• Simple yet extremely powerful.
• Cross Platform
• Integrates with just about anything.
• Excellent analytic capability.
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
SAS & Python = Awesome x 2. SAS have been busy in providing Python wrappers and Interfaces in
conjunction with other languages.
Python Library Suitable For
Python-SWAT SAS Viya™
SAS_kernel Integration with Jupyter Notebooks
saspy Interface for SAS 9x
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
How Does it Help Me? You can now leverage the strengths
of other languages.
SAS and Viya is your analytics and data hub.
Does not replace SAS. It expands the scope of SAS.
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Am I Running Python or SAS?
Python is the vehicle. SAS is the engine.
Python Programmers can use familiar programming patterns and tools.
SAS can augment Python, Python can augment SAS.
Viya allows Python to query Big Datasets efficiently.
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Overview
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
The Python-SWAT Library SAS Scripting Wrapper for Analytics Transfer
(SWAT)
Built on top of a popular Python programming interface called Pandas.
Two flavours, a binary and a REST Service interface. Binary library requires Linux and the numactl
package. REST client available for Windows, *nix, OSX etc. It’s open source! https://github.com/sassoftware/python-swat
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Installation Installation via standard Python mechanismspip install https://github.com/sassoftware/python-
swat/releases/download/vX.X.X/python-swat-X.X.X-platform.tar.gz
Invocation is simple;import swat
cas = swat.CAS(host=‘’,port=‘’,method=‘cas’user=‘’,password=’’)
Load actionsets based on your licensingcas.loadactionset('simple')
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Knowing What’s WhatDocumentation!
https://sassoftware.github.io/python-swat/index.html
## To see all available methods
cas.help()
## To see help for a specific actionset
cas.help(actionset='simple')
## Help for a specific Action
cas.help(action='regression')
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Managing Datademo_csv = 'https://raw.githubusercontent.com/sassoftware/sas-viya-
programming/master/data/cars.csv’
ct = cas.read_csv(
demo_csv,
casout=dict(
name=’PYTHONCARS’,
caslib=’public’,
promote=True
)
)
sastable = cas.CASTable(name='SASCARS',caslib='public')
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Viewing / Querying Data Many of the Pandas Data Frame methods are available
tbl.head(),tbl.tail(),tbl.fetch(to=10),tbl.describe()
Column Reduction tbl[‘Cylinders’,’Origin’]
Grouping tbl.groupby(['Origin', 'Cylinders']).summary(subset=['Min', 'Max'])
Sorting tbl.sort_values(['MSRP']).head()
Sub-setting tbl.query(‘Val > 0 and Val2==‘foo’).head()
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
The Payoff
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Viya-bot Use a Web Service created in
Python to be the back end of a Slack Bot.
Submit commands to Viya
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Viya-bot Python is the middleware.
Runs CAS Actions and returns the results to Slack
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
From Chatbot to Viya Data loaded to Viya and now
available to any SAS application or other interface.
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Exploit in SAS Use the data for VA, Visual
Statistics, SAS Studio etc.
Copyright © 2017 SelerityTM - a trademark of Scorpio Software Services Pty Ltd.
Further Info SAS Developers
https://developer.sas.com/guides/python.html
The Source Code https://github.com/sassoftware/python-swat/
SAS Viya The Python Perspective https://github.com/sassoftware/sas-viya-the-python-
perspective
Selerity Blog https://seleritysas.com/blog