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!
proc delete data=mydblib.NEBLKTAB;
run;
1
PROC DELETEDATA=mydblib.NEBLKTAB;
2
RUN;
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!
data work.NEBLKDAT;
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.NEBLKDAT;
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;
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!
proc sql;
create table mydblib.NEBLKTAB (BULKLOAD=YES BL_USE_PIPE=NO
BL_DELETE_DATAFILE=NO )
as select * from work.NEBLKDAT;
quit;
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!
proc print data=mydblib.NEBLKTAB;
format bdate date7.;
title 'proc print of table';
run;
1
PROC PRINTDATA=mydblib.NEBLKTAB;
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.