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.
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
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')
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.