Source data comes from the standard 'sashelp.baseball' table. Two intermediate CAS tables, 'casuser.baseball_location' and 'casuser.baseball_stats', are created from this source to facilitate join demonstrations. No external data is directly read outside of 'sashelp'.
1 Code Block
CAS setup
Explanation : This block initializes a CAS session and assigns all available caslibs, allowing access and manipulation of data in CAS memory. The commented line `cas casauto terminate;` suggests an option to terminate an existing CAS session.
Copied!
/* cas casauto terminate; */
cas;
caslib _all_ assign;
1
/* cas casauto terminate;
2
*/
3
cas;
4
caslib _all_ assign;
5
2 Code Block
DATA STEP Data
Explanation : Creation of a new CAS table named 'baseball_location' in the 'casuser' caslib. This table is derived from 'sashelp.baseball', retaining only columns related to player identification and their position/team.
Copied!
data casuser.baseball_location;
set sashelp.baseball;
keep name team div division league position;
run;
1
DATA casuser.baseball_location;
2
SET sashelp.baseball;
3
keep name team div division league position;
4
RUN;
3 Code Block
DATA STEP Data
Explanation : Creation of a second CAS table named 'baseball_stats' in the 'casuser' caslib. This table is also derived from 'sashelp.baseball', but all location and team columns are dropped to isolate player statistics.
Copied!
data casuser.baseball_stats;
set sashelp.baseball;
drop team div division league position ;
run;
1
DATA casuser.baseball_stats;
2
SET sashelp.baseball;
3
drop team div division league position ;
4
RUN;
4 Code Block
OPTIONS Statement
Explanation : Sets 'casuser' as the default active caslib for subsequent CAS operations, thereby simplifying the syntax for referencing tables in this library.
Copied!
/* set the active CASLIB */
options caslib=casuser;
1
/* set the active CASLIB */
2
options caslib=casuser;
3
5 Code Block
PROC FEDSQL Data
Explanation : Executes a FedSQL query to perform a LEFT JOIN between the 'baseball_location' and 'baseball_stats' tables on the 'name' column. The result is stored in a new CAS table named 'fedsql'.
Copied!
/* FedSQL Left join example */
proc FEDSQL sessref=casauto;
create table fedsql as
select distinct a.div, a.division, a.league, a.position, a.team, b.*
from baseball_location as a left join
baseball_stats as b
on a.name=b.name;
quit;
Explanation : Loads the 'searchAnalytics' and 'deepLearn' CASL action sets. These action sets contain advanced functionalities, including specific join actions that will be used in the following blocks.
Explanation : Demonstrates the use of the 'dlJoin' action from the 'deepLearn' set to perform a left join. It joins 'baseball_location' with 'baseball_stats' using the 'name' column as an identifier, and creates an output table named 'dlJoin'.
Explanation : Illustrates the 'searchJoin' action from the 'searchAnalytics' set for a left join. It joins 'baseball_location' and 'baseball_stats' on the 'name' column, but with a more detailed column specification, including renaming to distinguish the 'name' columns of the left and right tables. The result is saved in the 'searchJoin' table.
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.
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.