Published on :
Data Manipulation INTERNAL_CREATION

Example: PROC CASUTIL

This code is also available in: Deutsch Français
This documentation presents an example of using the PROC CASUTIL procedure to manipulate data in the SAS© Cloud Analytic Services (CAS) environment. The example illustrates how to load an internal dataset (sashelp.cars), partition it by selecting observations based on specific criteria, and then modify the resulting table to keep only a subset of columns. It also shows how to print the resulting CAS table.
Data Analysis

Type : INTERNAL_CREATION


Examples use generated data (datalines) or SASHELP.

1 Code Block
PROC CASUTIL
Explanation :
The code begins by establishing a CAS session (`cas casauto`) and assigning a library (`libname mylib cas`) to access CAS tables.
The `proc casutil;` statement initializes the CASUTIL procedure.
1. The `load data=sashelp.cars casout='cars' replace;` statement loads the `sashelp.cars` dataset (an internal SAS dataset) into CAS memory under the name 'cars'. The `replace` option ensures that the table is replaced if it already exists.
2. The `partition casdata='cars' casout='carsWhere' replace where='MSRP>90000 and Make="Porsche"';` statement creates a new CAS table named 'carsWhere'. It is created by selecting rows from the 'cars' table where the 'MSRP' value is greater than 90,000 and 'Make' is "Porsche".
3. The `altertable casdata="carsWhere" keep={"make", "model", "MSRP"};` statement modifies the 'carsWhere' table to keep only the 'make', 'model', and 'MSRP' columns.
Finally, `proc print data=mylib.carsWhere;` displays the content of the modified 'carsWhere' CAS table.
Copied!
1cas casauto sessopts=(caslib='casuser');
2LIBNAME mylib cas;
3 
4PROC CASUTIL;
5 load DATA=sashelp.cars
6 casout='cars' replace;
7 partition casdata='cars'
8 casout='carsWhere' replace
9 where='MSRP>90000 and Make="Porsche"';
10 altertable casdata="carsWhere"
11 keep={"make", "model", "MSRP"};
12QUIT;
13PROC PRINT DATA=mylib.carsWhere;
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.