Published on :
ETL EXTERNAL

ETL Macro for Loading CAS Dimension

This code is also available in: Deutsch Español Français
Awaiting validation
This macro takes as input the name of a table and its library (default 'work'). It checks for the existence of the source table, loads it into memory in the CAS library via a Data Step, then uses the CASUTIL procedure to persistently save the table in the target CASLIB.
Data Analysis

Type : EXTERNAL


The macro expects an existing table provided as a parameter (variable &cas_indsn in library &lib).

1 Code Block
MACRO
Explanation :
Macro definition, default value management for the library (WORK), and verification of the source table's existence. If the table does not exist, the process stops.
Copied!
1%macro etl_dim_data_into_cas(cas_indsn,lib=);
2 
3 /*add data into cas*/
4 %IF "&lib"="" %THEN %DO;
5 %let lib=work;
6 %END;
7 
8 /*check if input dataset exists or not, if exists then not blank*/
9 %let dsn= &lib..&cas_indsn.;
10 %IF not %sysfunc(exist(&dsn.)) %THEN %DO;
11 %put ERROR: &dsn. does not exist. Exiting the process.;
12 %goto ERREXIT;
13 %END;
14
15 %let cas_indsn=%upcase(%qleft(%qtrim(%bquote(&cas_indsn.))));
2 Code Block
DATA STEP Data
Explanation :
Loading data from the source library to the CAS library (libref 'mycas') via a Data Step.
Copied!
1 DATA mycas.&cas_indsn.;
2
3 SET &lib..&cas_indsn.;
4 RUN;
3 Code Block
PROC CASUTIL
Explanation :
Persistent saving of the table loaded in memory to the 'mycaslib' CASLIB disk using the CASUTIL procedure.
Copied!
1 PROC CASUTIL incaslib="mycaslib" outcaslib="mycaslib";
2 save casdata="&cas_indsn." replace;
3 RUN;
4 %ERREXIT:
5%mend;
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 (C) 2021 SAS Institute, Inc. All rights reserved.