While the PARTITION statement in PROC CASUTIL is often associated with creating data partitions for sampling, it is also highly effective as a high-performance filtering tool (as shown in your code with where='...'); unlike a standard DATA step which processes row-by-row, this method performs the subsetting directly in the CAS server's memory, often resulting in faster execution for large datasets.
Use PROC CASUTIL for efficient, code-lite management of in-memory tables.
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.
Perform your column selection (KEEP) and row filtering (WHERE) as early as possible—ideally during the load or partition phase—to minimize the memory footprint of your CAS session.
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.
Related Documentation
Aucune documentation spécifique pour cette catégorie.
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.