Published on :
ETL MIXTE

Copying data from an ODBC source to local files

This code is also available in: Deutsch Español Français
Awaiting validation
The script initializes SAS© options for dataset compression (`compress=yes`) and variable name flexibility (`validvarname=any`). It then defines two libraries: `dwdata` for an ODBC connection to an external data source of the same name, and `dwRaw` for a directory on the local file system (specifically 'D:\mili\Datamart\rawdata\dwdata'). Two DATA steps are used to read the `risk_creditx_resp` and `risk_bqs_req` tables from the `dwdata` library (ODBC source) and write them respectively as `creditx_hit_rule` and `risk_bqs_req` in the `dwRaw` library (local files). The goal is to transfer data from an external database via ODBC to local SAS© files for further processing or archiving.
Data Analysis

Type : MIXTE


Source data is extracted from tables (`risk_creditx_resp`, `risk_bqs_req`) via an ODBC connection (`libname dwdata`). Output data is written as SAS datasets to a directory on the local file system (`libname dwRaw`).

1 Code Block
Options and Libnames
Explanation :
This block initializes global SAS options for disk space management (compression) and variable name validity. It also defines two libraries: `dwdata` to access a data source via ODBC and `dwRaw` to point to a specific directory on the local file system, where the data will be stored.
Copied!
1option compress = yes validvarname = any;
2 
3LIBNAME dwdata odbc datasrc = dwdata;
4LIBNAME dwRaw "D:\mili\Datamartawdata\dwdata";
2 Code Block
DATA STEP Data
Explanation :
This DATA step reads the `risk_creditx_resp` dataset from the `dwdata` library (ODBC source). It then creates a copy of this dataset, named `creditx_hit_rule`, in the `dwRaw` library (local files). This is a simple data copying operation.
Copied!
1 
2DATA dwRaw.creditx_hit_rule;
3SET dwdata.risk_creditx_resp;
4RUN;
5 
3 Code Block
DATA STEP Data
Explanation :
Similar to the previous block, this DATA step reads the `risk_bqs_req` dataset from the `dwdata` library (ODBC source) and copies it under the same name to the `dwRaw` library (local files). This operation also transfers data from an external source to local storage.
Copied!
1 
2DATA dwRaw.risk_bqs_req;
3SET dwdata.risk_bqs_req;
4RUN;
5 
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.