CAS Joins with Deep Learning and Search Analytics

This code is also available in: Deutsch Español Français
Difficulty Level
Beginner
Published on :
Attention : This code requires administrator privileges.
The script begins by establishing a CAS connection and assigning all CAS libraries. It then creates two CAS tables, 'casuser.baseball_location' and 'casuser.baseball_stats', by selecting and manipulating columns from the source table 'sashelp.baseball'. The active CAS session is then set to 'casuser'. Finally, it loads the 'searchAnalytics' and 'deepLearn' action sets and executes examples of 'dlJoin' and 'searchJoin' actions to demonstrate 'APPEND' type join operations on the created tables, producing the 'dlJoin' and 'searchJoin' tables in CAS.
Data Analysis

Type : SASHELP


Initial source data comes from the standard SASHELP library ('sashelp.baseball'). Two new tables ('casuser.baseball_location' and 'casuser.baseball_stats') are created in the 'CASUSER' CAS library from this source.

1 Code Block
CAS
Explanation :
This block initializes a CAS (Cloud Analytic Services) session and assigns all available CAS libraries to the user. This is a common administrative operation that makes libraries accessible for data operations.
Copied!
1cas;
2caslib _all_ assign;
2 Code Block
DATA STEP Data
Explanation :
This DATA STEP creates a new CAS table named 'baseball_location' in the 'CASUSER' library. It selects specific columns ('name', 'team', 'div', 'division', 'league', 'position') from the source table 'sashelp.baseball', retaining only player location and team information.
Copied!
1DATA casuser.baseball_location;
2 SET sashelp.baseball;
3 keep name team div division league position;
4RUN;
3 Code Block
DATA STEP Data
Explanation :
This DATA STEP creates another CAS table named 'baseball_stats' in the 'CASUSER' library. It is also based on 'sashelp.baseball', but this time it drops location and team columns, retaining only player statistics, to prepare for a subsequent join.
Copied!
1DATA casuser.baseball_stats;
2 SET sashelp.baseball;
3 drop div division league position ;
4RUN;
4 Code Block
SAS GLOBAL
Explanation :
This 'options' statement sets the default CAS library ('caslib') to 'casuser'. This means that all subsequent CAS operations that do not explicitly specify a caslib will use 'casuser'.
Copied!
1options caslib=casuser;
5 Code Block
PROC CAS
Explanation :
This 'PROC CAS' block is used to load specific action sets required for subsequent operations. It loads 'searchAnalytics' and 'deepLearn', which contain actions for advanced analytics and joins specific to search and deep learning contexts.
Copied!
1PROC CAS;
2LOADACTIONSET 'searchAnalytics';
3LOADACTIONSET 'deepLearn';
4QUIT;
6 Code Block
PROC CAS Data
Explanation :
This 'PROC CAS' block executes the 'dlJoin' action from the 'deepLearn' action set. It performs an 'APPEND' type join (appending rows) between 'baseball_location' (annotated table) and 'baseball_stats' (main table). The result is a new CAS table named 'dlJoin', replacing any existing table with the same name.
Copied!
1PROC CAS;
2 DEEPLEARN.dlJoin /
3 joinType="APPEND"
4 annotatedTable={name="baseball_location"}
5 casOut={name="dlJoin", replace=TRUE}
6 TABLE={name="baseball_stats"};
7 RUN;
8QUIT;
7 Code Block
PROC CAS Data
Explanation :
This 'PROC CAS' block uses the 'searchJoin' action from the 'searchAnalytics' action set. It also performs an 'APPEND' type join using 'baseball_location' as the left table and 'baseball_stats' as the right table. The result is stored in a new CAS table named 'searchJoin', replacing any existing table.
Copied!
1PROC CAS;
2 searchAnalytics.searchJoin /
3 joinType="APPEND"
4 casOut={name="searchJoin", replace=TRUE}
5 leftTable={
6 TABLE={name="baseball_location"}
7 }
8 rightTable={
9 TABLE={name="baseball_stats"}
10 };
11RUN;
12QUIT;
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


Related Documentation

Aucune documentation spécifique pour cette catégorie.