13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

36 The KEEP= and DROP= Options 4 Chapter 4table that you want from the list of tables, and select the member that you want to seethe contents of the table.Likewise, select only the DBMS columns that your program needs. Selectingunnecessary columns slows your job.The KEEP= and DROP= OptionsJust as with a <strong>SAS</strong> data set you can use the DROP= and KEEP= data set options toprevent retrieving unneeded columns from your DBMS table.In this example the KEEP= data set option causes the <strong>SAS</strong>/<strong>ACCESS</strong> engine to selectonly the SALARY and DEPT columns when it reads the MYDBLIB.EMPLOYEES table.libname mydblib db2 user=testid password=testpass database=testdb;proc print data (keep=salary dept);where dept=’ACC024’;quit;The generated SQL that the DBMS processes is similar to the following code:SELECT "SALARY", "DEPT" FROM EMPLOYEESWHERE(DEPT="ACC024")Without the KEEP option, the SQL processed by the DBMS would be similar to thefollowing:SELECT * FROM EMPLOYEESWHERE(DEPT="ACC024")This would result in all of the columns from the EMPLOYEES table being read in to<strong>SAS</strong>.The DROP= data set option is a parallel option that specifies columns to omit fromthe output table. Keep in mind that the DROP= and KEEP= data set options are notinterchangeable with the DROP and KEEP statements. Use of the DROP and KEEPstatements when selecting data from a DBMS can result in retrieval of all column into<strong>SAS</strong>, which can seriously impact per<strong>for</strong>mance.For example, the following would result in all of the columns from the EMPLOYEEStable being retrieved into <strong>SAS</strong>. The KEEP statement would be applied when creatingthe output data set.libname mydblib db2 user=testid password=testpass database=testdb;data temp;set mydblib.employees;keep salary;run;The following is an example of how to use the KEEP data set option to retrieve onlythe SALARY column:data temp;set mydblib.employees(keep=salary);run;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!