The script begins by establishing a CAS library (CASLIB) pointing to 'casuser'. It then configures the 'USER' option to direct the creation of single-level tables to this CASLIB. A demonstration table named 'baseball' is created in CAS from the 'sashelp.baseball' table. Finally, the script uses PROC CAS and the 'table.alterTable' action to rename the 'baseball' table to 'baseball' followed by a date (extracted from a macro variable) in the 'casuser' CASLIB.
Data Analysis
Type : SASHELP
The data used for creating the CAS table 'baseball' comes from the standard SASHELP table 'sashelp.baseball'.
1 Code Block
DATA STEP Data
Explanation : This block initializes a CAS library named 'CASWORK' linked to the 'casuser' CASLIB. It also sets 'CASWORK' as the default library for single-level table names. A CAS table 'baseball' is then created in this CASLIB from 'sashelp.baseball'. A macro variable 'mydate' is defined, and the default CASLIB for CAS actions is set to 'casuser'.
Copied!
libname CASWORK cas caslib=casuser;
options USER = CASWORK;
%put &_sessref_;
data CASWORK.baseball;
set sashelp.baseball;
run;
%let mydate=20Apr2020;
%put &mydate;
options caslib="casuser";
1
LIBNAME CASWORK cas caslib=casuser;
2
options USER = CASWORK;
3
4
%put &_sessref_;
5
6
DATA CASWORK.baseball;
7
SET sashelp.baseball;
8
RUN;
9
10
%let mydate=20Apr2020;
11
%put &mydate;
12
options caslib="casuser";
2 Code Block
PROC CAS
Explanation : This block uses the CAS procedure (PROC CAS) to execute the 'table.alterTable' action. This action is used to rename the 'baseball' table located in the 'casuser' CASLIB to 'baseball20Apr2020', using the value of the macro variable 'mydate'.
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.