Published on :

Baseball Statistics Analysis with CAS

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by initializing the CAS session and assigning all available CASLIBs. Then, it uses a DATA STEP to copy the 'sashelp.baseball' dataset to a new CAS table named 'baseball_stats' in the 'casuser' CASLIB. Once the data is in CAS, 'PROC MEANS' is executed on 'casuser.baseball_stats' to calculate descriptive statistics. Finally, the script lists the complete history of CAS session actions, which is useful for debugging and auditing.
Data Analysis

Type : SASHELP


The source dataset 'sashelp.baseball' is an internal table provided by SAS. It is loaded into the 'casuser' CAS library before being used for analysis.

1 Code Block
CAS Session Management
Explanation :
These commands initialize a CAS session and assign all available CAS libraries (CASLIBs), making CAS tables accessible for processing.
Copied!
1cas;
2caslib _all_ assign;
2 Code Block
DATA STEP Data
Explanation :
This DATA STEP creates a new CAS table named 'baseball_stats' in the 'casuser' CASLIB. It copies data from the SASHELP dataset 'sashelp.baseball' into this new table. The execution of this DATA STEP occurs on the CAS server.
Copied!
1 
2DATA casuser.baseball_stats;
3SET sashelp.baseball;
4RUN;
5 
3 Code Block
PROC MEANS
Explanation :
The MEANS procedure is executed on the CAS table 'casuser.baseball_stats' to generate descriptive statistics (such as mean, minimum, maximum, standard deviation) for all numeric variables present in the table.
Copied!
1PROC MEANS DATA=casuser.baseball_stats;
2RUN;
4 Code Block
CAS Action
Explanation :
This CAS action lists the complete history of operations and actions executed in the 'casauto' CAS session. It is a useful tool for tracing and debugging CAS processes.
Copied!
1cas casauto listhistory _all_;
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.
Copyright Info : Copyright © 2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. SPDX-License-Identifier: Apache-2.0