The initial data is created internally via a DATA STEP with `datalines` (`work.DUBLKDAT`). It is then transferred to an external database table (`mybulk.DUBLKTAB`) via ODBC.
1 Code Block
LIBNAME Statement
Explanation : Assigns a SAS libname named `mybulk` to an external data source. The macro variables `&dbms` and `&connopt` should contain the specific database connection information (likely ODBC). The `bcp=yes` option enables the bulk copy protocol, typically used with SQL Server, for optimized data transfers.
Copied!
libname mybulk &dbms &connopt bcp=yes;
1
LIBNAME mybulk &dbms &connopt bcp=yes;
2 Code Block
PROC DELETE
Explanation : Deletes the `DUBLKTAB` table from the external data source (identified by the `mybulk` libname). This ensures that any previous execution does not leave residues, allowing for a clean recreation of the table.
Copied!
proc delete data=mybulk.DUBLKTAB;
run;
1
PROC DELETEDATA=mybulk.DUBLKTAB;
2
RUN;
3 Code Block
DATA STEP Data
Explanation : Creates a temporary SAS dataset named `work.DUBLKDAT`. The data is defined inline using the `cards;` statement. This dataset contains four variables: `name` (character), `age` (numeric), `sex` (character), and `bdate` (date in MMDDYY format).
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;
4 Code Block
DATA STEP Data
Explanation : This DATA STEP reads the `work.DUBLKDAT` dataset and writes its records to a new database table named `DUBLKTAB` under the `mybulk` libname. This is the step where the bulk loading of data to the external database occurs.
Copied!
data mybulk.DUBLKTAB;
set work.DUBLKDAT;
run;
1
DATA mybulk.DUBLKTAB;
2
SET work.DUBLKDAT;
3
RUN;
5 Code Block
PROC PRINT
Explanation : Displays the contents of the `DUBLKTAB` table from the external database. The `format bdate date7.;` statement is used to display the `bdate` variable in a readable date format (DDMMMYY). The title 'proc print of table' is added to the output.
Copied!
proc print data=mybulk.DUBLKTAB;
format bdate date7.;
title 'proc print of table';
run;
1
PROC PRINTDATA=mybulk.DUBLKTAB;
2
FORMAT bdate date7.;
3
title 'proc print of table';
4
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.
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.