Published on :
ETL MIXTE

Bulk Data Loading

This code is also available in: Deutsch Español Français English
Awaiting validation
The script is designed to demonstrate the use of the SAS©/ACCESS BULKLOAD functionality. It performs the following steps:
1. Cleanup: Deletes a target table (`mydblib.NEBLKTAB`) if it exists, thus preparing the environment for a new load.
2. Source Data Creation: A temporary SAS© dataset (`work.NEBLKDAT`) is created internally using a DATA STEP and `CARDS` data (datalines), simulating the data to be loaded.
3. Bulk Loading: PROC SQL is used to create a table in the external database (`mydblib.NEBLKTAB`) from the SAS© dataset `work.NEBLKDAT`. The options `BULKLOAD=YES`, `BL_USE_PIPE=NO`, and `BL_DELETE_DATAFILE=NO` are specified to optimize the bulk loading process.
4. Verification: Finally, a PROC PRINT is executed to display the content of the newly created table in the external database, confirming the successful load.
Data Analysis

Type : MIXTE


Initial data is created internally via a DATA STEP and the CARDS statement (`work.NEBLKDAT`). It is then loaded into a table (`mydblib.NEBLKTAB`) in an external database via the `mydblib` library. Although the target is external, the direct source of the loaded data is internal to the script.

1 Code Block
PROC DELETE
Explanation :
This block deletes the `NEBLKTAB` table in the `mydblib` library (which points to the external database) if it exists. This is a typical cleanup step before recreating or reloading data.
Copied!
1PROC DELETE DATA=mydblib.NEBLKTAB;
2RUN;
2 Code Block
DATA STEP Data
Explanation :
This DATA STEP creates a temporary dataset named `NEBLKDAT` in the `work` library. It defines the variables `name`, `age`, `sex`, and `bdate` (with the `mmddyy.` date format). The data is provided directly in the script via the `cards` statement. This dataset will serve as the source for subsequent bulk loading.
Copied!
1DATA work.NEBLKDAT;
2 INPUT name $ age sex $ bdate mmddyy.;
3 CARDS;
4amy 3 f 030185
5bill 12 m 121277
6charlie 35 m 010253
7david 19 m 101469
8elinor 42 f 080845
9pearl 78 f 051222
10vera 96 f 101200
11frank 24 m 092663
12georgia 1 f 040687
13henry 46 m 053042
14joann 27 f 020461
15buddy 66 m 101432
16;
17RUN;
3 Code Block
PROC SQL
Explanation :
This block uses PROC SQL to create a table named `NEBLKTAB` in the external database via the `mydblib` library. The `as select * from work.NEBLKDAT` clause indicates that the table is populated with data from the SAS dataset `work.NEBLKDAT`. The options `BULKLOAD=YES`, `BL_USE_PIPE=NO`, and `BL_DELETE_DATAFILE=NO` are SAS/ACCESS-specific parameters to control the behavior of bulk loading to the database. `BULKLOAD=YES` enables bulk loading.
Copied!
1PROC SQL;
2create TABLE mydblib.NEBLKTAB (BULKLOAD=YES BL_USE_PIPE=NO
3 BL_DELETE_DATAFILE=NO )
4 as select * from work.NEBLKDAT;
5QUIT;
4 Code Block
PROC PRINT
Explanation :
This block uses PROC PRINT to display the content of the `NEBLKTAB` table, recently created and loaded into the external database. The `date7.` format is applied to the `bdate` variable for better readability, and a title is added to the output.
Copied!
1PROC PRINT DATA=mydblib.NEBLKTAB;
2 FORMAT bdate date7.;
3title 'proc print of table';
4RUN;
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 : S A S S A M P L E L I B R A R Y