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!
data work.DUBLKDAT;
input name $ age sex $ bdate mmddyy.;
cards;
amy 3 f 030185
bill 12 m 121277
charlie 35 m 010253
david 19 m 101469
elinor 42 f 080845
pearl 78 f 051222
vera 96 f 101200
frank 24 m 092663
georgia 1 f 040687
henry 46 m 053042
joann 27 f 020461
buddy 66 m 101432
;
run;
1
DATA work.DUBLKDAT;
2
INPUT name $ age sex $ bdate mmddyy.;
3
CARDS;
4
amy 3 f 030185
5
bill 12 m 121277
6
charlie 35 m 010253
7
david 19 m 101469
8
elinor 42 f 080845
9
pearl 78 f 051222
10
vera 96 f 101200
11
frank 24 m 092663
12
georgia 1 f 040687
13
henry 46 m 053042
14
joann 27 f 020461
15
buddy 66 m 101432
16
;
17
RUN;
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!
proc sql;
create table mydblib.DUBLKTAB (
BULKLOAD=YES
bl_path=&bl_path
bl_dbname=&bl_dbname
bl_host=&bl_host
) as select * from work.DUBLKDAT;
quit;
1
PROC SQL;
2
create 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;
8
QUIT;
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!
proc print data=mydblib.DUBLKTAB;
format bdate date7.;
title 'proc print of table';
run;
1
PROC PRINTDATA=mydblib.DUBLKTAB;
2
FORMAT bdate date7.;
3
title 'proc print of table';
4
RUN;
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!
proc delete data=mydblib.DUBLKTAB;
run;
1
PROC DELETEDATA=mydblib.DUBLKTAB;
2
RUN;
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
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.