Python to viya


The SAS SWAT package is a Python interface to SAS Cloud Analytic Services (CAS) .
With this package, you can load and analyze data sets of any size on your desktop or in the cloud. Since CAS can be used on a local desktop or in a hosted cloud environment, you can analyze extremely large data sets using as much processing power as you need, while still retaining the ease-of-use of Python on the client side.

可參考Github python-swat
SWAT project releases page

SAS Viya programming-python
內容之一
Getting Started with SWAT



$ python -m module [arg]  直接調用模組

$ python -m pip install https://github.com/sassoftware/python-swat/archive/v1.4.0.tar.gz



import swat

連到CASip修改
conn = swat.CAS('your_host',8777,'XXXXXXX','*******',protocol='http')

#server狀態
out = conn.serverstatus()
out


# list all loaded actionsets# list 

conn.builtins.actionSetInfo()


# load in new actionset
conn.builtins.loadActionSet('decisionTree')

# get help again
conn.help().decisionTree

原本只有
conn.help().decisionTree
會找不到東西

help(conn.decisionTree.gbtreeTrain)

#casout可以命名table name

tbl = conn.read_csv('https://raw.githubusercontent.com/sassoftware/sas-viya-programming/master/data/cars.csv',casout='cars')

# 檢視目前CAS上的資料(in-memory)
conn.tableinfo()

#summary action
out = conn.summary(table=tbl)
out

#也可以
out = tbl.summary()
out

結束
conn.close()

留言