Published on :
ETL INTERNAL_CREATION

Bulkload Example

This code is also available in: Deutsch Español Français
Awaiting validation
The script initializes global macros to configure bulkload parameters (path, database name, host). It then proceeds to create a temporary dataset `work.DUBLKDAT` using a `DATA STEP` block with inline data (`cards;`). The main part uses `PROC SQL` to create a table `mydblib.DUBLKTAB` in an external database management system (DBMS), specifying `BULKLOAD=YES` and using global macros for connection parameters. The script also includes a `PROC PRINT` to verify the content of the loaded table and a `PROC DELETE` to clean up the DBMS table after execution.
Data Analysis

Type : INTERNAL_CREATION


Data is created directly within the script via a `DATA STEP` using the `cards;` statement. No external data source is read by the script itself.

1 Code Block
DATA STEP Data
Explanation :
This `DATA STEP` block creates a temporary dataset named `work.DUBLKDAT` using data provided directly in the script (inline) via the `cards;` statement. The variables `name`, `age`, `sex`, and `bdate` are defined, with `bdate` formatted as a SAS date.
Copied!
1DATA work.DUBLKDAT;
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;
2 Code Block
PROC SQL
Explanation :
This `PROC SQL` creates a new table named `DUBLKTAB` in the `mydblib` library (which represents a connection to an external database). The `BULKLOAD=YES` option is specified to enable bulk loading, and global macros (`bl_path`, `bl_dbname`, `bl_host`) are used to configure the bulk loader parameters. The table content is populated by selecting all columns from the previously created `work.DUBLKDAT` dataset.
Copied!
1PROC SQL;
2create TABLE mydblib.DUBLKTAB (
3 BULKLOAD=YES
4 bl_path=&bl_path
5 bl_dbname=&bl_dbname
6 bl_host=&bl_host
7) as select * from work.DUBLKDAT;
8QUIT;
3 Code Block
PROC PRINT
Explanation :
This `PROC PRINT` displays the content of the `mydblib.DUBLKTAB` table that was loaded into the DBMS. The `date7.` format is applied to the `bdate` column for better readability. A title is also added to the output.
Copied!
1PROC PRINT DATA=mydblib.DUBLKTAB;
2 FORMAT bdate date7.;
3title 'proc print of table';
4RUN;
4 Code Block
PROC DELETE
Explanation :
This `PROC DELETE` is used to remove the `mydblib.DUBLKTAB` table from the DBMS, thus performing a cleanup after the example's execution.
Copied!
1PROC DELETE DATA=mydblib.DUBLKTAB;
2RUN;
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 NAME: bulkload.sas TITLE: Sample Programs PRODUCT: SAS/ACCESS to Aster SYSTEM: z/OS, UNIX, WINDOWS REF: SAS/ACCESS 9 for Relational Databases: Reference