SAS® Viya™: Load a CSV File to a Caslib
Once you have connected to a CAS session you are able to load data into CAS. To perform this task, a Snippet is available within SAS Studio named 'Load data to caslib'.
The snippet contains three sections dependent on the data you would like to load into a caslib. When data is loaded into a caslib, three options are required on the statement:
Option | Description |
Outcaslib | The caslib to load the data into. |
Casout | The table name you would like to call the in-memory table within CAS. |
Promote | (Optional) Specifies that the data loaded will be available to all active CAS sessions. |
In addition to these three options, each section has additional options which are required to load specific types of data.
Load file from a client location
The first section within the snippet allows users to load data directly from a directory on the SAS Viya server.
To load a file from a client location the 'load file' option is required. This option specifies the file which you would like to load into the caslib, within double quotation marks.
Load a CSV file into CAS
To demonstrate how to load a CSV file into CAS,
To load a CSV file into CAS, the 'importoptions' option is required. This specifies the file type which we would like to import into CAS, in the following example we have specified that this is a csv file.
The following file types can also be read into CAS directly:
- Basesas
- Dta
- Excel
- Hdat
- Lasr
- Xls
When the code is run, the log details that the CSV file has been loaded into CAS sucessfully.