Export CASTable data

SAS Viya is an AI platform. It is available through languages such as Python, Java and R. A table object called CASTable is used in SAS Viya (CAS stands for Cloud Analytic Services). This time, I will show you how to export CASTable data.

Get a table from the database

First, connect to SAS Viya.

import swat
conn = swat.CAS('server-name.mycompany.com', 5570, 'username', 'password')

Then get the CASTable. This time, I will use CSV of IRIS data.

tbl = conn.loadtable('data/iris.csv', caslib='casuser').casTable

Export

For example, when exporting as CSV, do as follows.

tbl.save(name='data/irisout.csv', caslib='casuser')

If the file already exists, a message will be displayed.

The file /u/username/data/irisout.csv already exists. Specify the replace option to overwrite an existing file.
The action stopped due to errors.

To output in SAS file format SASHDAT, do as follows.

tbl.save(name='data/irisout.sashdat', caslib='casuser')

Summary

Export does not require a file format to be specified and is automatically determined by the file extension. Please note that the file is saved on the server side.

SAS for Developers | SAS

Recommended Posts

Export CASTable data
Export 3D data from QGIS
Export DB data in json format
Check the data summary in CASTable
Get the column list & data list of CASTable
Data handling
Visualize the export data of Piyo log