BookmarkSubscribeRSS Feed

The Video Guide To Importing Local Files into CAS on SAS Viya

Started ‎05-31-2021 by
Modified ‎05-31-2021 by
Views 5,557

When you need to import a local file from your PC into CAS, on SAS Viya 2020.1 or later, these short videos will guide you. The code snippets mentioned in the video are provided in the post.


The Local File Import in 30 Seconds

If you only have 30 seconds, here is the condensed summary:





  1. Use the Visual Interfaces: SAS Environment Manager, SAS Visual Analytics, SAS Data Explorer or SAS Information Catalog.
  2. Write code: PROC CASUTIL (load file) or PROC CAS (upload action).
  3. Use the SAS Studio code snippet: generates PROC IMPORT.
  4. Use SAS Studio flow: generates a DATA STEP.
  5. Use Python with the SWAT package. Will be discussed in a separate post.


Use the Visual Interfaces



The SAS Viya Administration documentation does an excellent job at explaining the import options.


Write Code




Make the file available to SAS Studio

First you need to upload the file in a location which is visible and accessible by SAS Compute. The location can be:

  • A folder on a Network File Share (mypath in the code snippet below).
  • A folder in SAS Content. By default, a LOCKDOWN is enabled by default for all the SAS Compute servers. You need to take certain steps to be able to define a CASLIB on that location (folder in the code snippet below).


Session definition and file location

* Wrapper code;
CAS mySession  SESSOPTS=( CASLIB="casuser" TIMEOUT=999 LOCALE="en_US" metrics=true);
options msglevel=i ;
caslib _all_ assign;
%put My Userid is: &sysuserid;

* File created on NFS;
%let mypath1=/gelcontent/gelcorp/shared/data/ ;
%let csvdata=&mypath1.prdsale.csv;

* This location is in lockdown state;
*%let folder=/Users/&sysuserid/My Folder/;
*%let csvdata2=&folder.prdsale.csv;


See the following resources for external path based data:




* Drop in-memory CAS table;
proc casutil ;    droptable casdata="prdsale_proccasutil" incaslib="casuser" quiet; quit ;

* Proc casutil - file load .csv from client machine to CAS library;
proc casutil ;
   load file="&csvdata"
        outcaslib='casuser' casout="prdsale_proccasutil" copies=0  promote; quit;

PROC CAS example


* Drop in-memory CAS table;
proc casutil ;
   droptable casdata="prdsale_proccas" incaslib="casuser" quiet;
quit ;

* table.upload cas action;
proc cas;
upload result=r status=rc /
label="CSV file from client",
importOptions={fileType="CSV", vars={{name="ACTUAL", format="DOLLAR8.2"}}

PROC Import example


/* Import a csv file from the location specified on the filename statement */
/* The SAS data set created is named by substituting a name for work.mycsv */

filename csv "&csvdata.";

/* Import the CSV file  */
proc import datafile=csv out=casuser.prdsale_import replace dbms=csv;

/* Print the first 10 observations **/
proc print data=casuser.prdsale_import(obs=10);

filename csv;

* Add a promote statement;
proc cas;
table.promote name='prdsale_import' caslib='casuser'; quit;



To import a local file into CAS:

  • Use the visual interfaces.
  • Write your own PROC CASUTIL, which should be the easiest and most efficient coding option.
  • Write a PROC CAS, if you need to fine-tune the import options.
  • Use a code snippet in SAS Studio.
  • Use SAS Studio flow, a visual interface that generates code.


I would recommend the following resources:

SAS Viya 2020.1 and later

SAS Viya 3.5


@StephenFoerster , @MKQueen , @NicolasRobert , @UttamKumar , @GerryNelson 


Thank you for your time reading this post. Please comment and share your experience with the Local File Import in CAS and help others. If you wish to get more information, please leave a comment.


Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎05-31-2021 09:50 PM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started