The example shows how to load a local CSV file ('County_Population.csv') into a CAS caslib, thereby creating a CAS table from external data. The IMPORTOPTIONS=(filetype="csv" getnames="true") option is used to specify the file type and ensure that column names are imported correctly. Access to the data source is managed via a DNFS (Distributed Network File System) type caslib.
1 Code Block
PROC CASUTIL Data
Explanation : This SAS code illustrates the process of loading a CSV file into SAS Cloud Analytic Services (CAS). The first step is to define a caslib named 'csvfiles' of type DNFS, specifying the path to the CSV files. This allows CAS to access the data stored in this directory. Then, the PROC CASUTIL procedure is used to list the available files in this caslib (list files). The 'load' command is then employed to load the 'County_Population.csv' file into CAS. The 'importoptions=(filetype="csv" getnames="true")' option indicates that the file is in CSV format and that the first row contains the variable names. The resulting CAS table will be named 'county_population'. Finally, 'list tables' displays the CAS tables currently loaded in the caslib.
Copied!
caslib csvfiles task=add type=dnfs
path="/data/csv/"
desc="Spreadsheets and CSV source data.";
proc casutil;
list files;
load casdata="County_Population.csv"
importoptions=(filetype="csv" getnames="true")
casout="county_population";
list tables;
quit;
1
caslib csvfiles task=add type=dnfs
2
path="/data/csv/"
3
desc="Spreadsheets and CSV source data.";
4
5
PROC CASUTIL;
6
list files;
7
8
load casdata="County_Population.csv"
9
importoptions=(filetype="csv" getnames="true")
10
casout="county_population";
11
12
list tables;
13
QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« In the SAS Viya ecosystem, PROC CASUTIL serves as the primary "utility knife" for managing data between your persistent storage (physical files) and the CAS in-memory environment. Unlike standard Base SAS procedures, CASUTIL is specifically optimized to handle the distributed nature of Cloud Analytic Services, ensuring that data is loaded and managed across all worker nodes efficiently. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.