Published on :
ETL SASHELP

Loading and Manipulation of Baseball Data in CAS

This code is also available in: Deutsch Español Français
Awaiting validation
The script initializes a CAS session and assigns all caslibs. It then uses two DATA steps to: 1) Copy the 'baseball' table from SASHELP to the 'casuser' caslib under the same name. 2) Create a new 'baseball2' table in the 'casuser' caslib from 'casuser.baseball', calculating a new variable 'x' as the ratio of 'nruns' divided by 'nhits'. The entire process runs entirely within the Cloud Analytic Services (CAS) engine.
Data Analysis

Type : SASHELP


The primary data source is the 'baseball' table from the SASHELP library, which is an example data library provided by SAS. This data is then copied and manipulated within the 'casuser' caslib.

1 Code Block
CAS Configuration
Explanation :
This block configures the CAS session by enabling metrics collection and assigning all available caslibs, which allows access and manipulation of data stored in CAS.
Copied!
1cas sessopts=(metrics=true);
2caslib _all_ assign;
2 Code Block
DATA STEP Data
Explanation :
This DATA step creates a new table named 'baseball' in the 'casuser' caslib. It copies all observations and variables from the 'sashelp.baseball' table to the CAS table, making the data available for distributed processing in CAS.
Copied!
1 
2DATA casuser.baseball;
3SET sashelp.baseball;
4RUN;
5 
3 Code Block
DATA STEP Data
Explanation :
This second DATA step creates a new CAS table named 'baseball2' from the previously created 'casuser.baseball' table. It introduces a new variable 'x' calculated as the ratio of 'nruns' and 'nhits' for each observation. This operation is executed directly in CAS.
Copied!
1DATA casuser.baseball2;
2 SET casuser.baseball;
3 x=nruns/nhits;
4RUN;
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