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.

Data Set Options <strong>for</strong> <strong>Relational</strong> <strong>Databases</strong> 4 DB<strong>SAS</strong>TYPE= Data Set Option 315Syntax Descriptioncolumn-namespecifies a DBMS column name.<strong>SAS</strong>-data-typespecifies a <strong>SAS</strong> data type, which can be CHAR(n), NUMERIC, DATETIME, DATE,TIME. See your <strong>SAS</strong>/<strong>ACCESS</strong> interface documentation <strong>for</strong> details.DetailsBy default, the <strong>SAS</strong>/<strong>ACCESS</strong> interface <strong>for</strong> your DBMS converts each DBMS data typeto a <strong>SAS</strong> data type during input processing. When you need a different data type, youcan use this option to override the default and assign a <strong>SAS</strong> data type to each specifiedDBMS column. Some conversions might not be supported. In that case, <strong>SAS</strong> prints anerror to the log.ExamplesIn this example, DB<strong>SAS</strong>TYPE= specifies a data type to use <strong>for</strong> the columnMYCOLUMN when <strong>SAS</strong> is printing ODBC data. <strong>SAS</strong> can print the values if the data inthis DBMS column is stored in a <strong>for</strong>mat that <strong>SAS</strong> does not support, such asSQL_DOUBLE(20).proc print data=mylib.mytable(dbsastype=(mycolumn=’CHAR(20)’));run;In the next example, data that is stored in the DBMS FIBERSIZE column has a datatype that provides more precision than what <strong>SAS</strong> could accurately support, such asDECIMAL(20). If you use only PROC PRINT on the DBMS table, the data might berounded or display as a missing value. So you could use DB<strong>SAS</strong>TYPE= instead toconvert the column so that the length of the character field is 21. The DBMS per<strong>for</strong>msthe conversion be<strong>for</strong>e the data is brought into <strong>SAS</strong>, so precision is preserved.proc print data=mylib.specprod(dbsastype=(fibersize=’CHAR(21)’));run;The next example uses DB<strong>SAS</strong>TYPE= to append one table to another when the datatypes cannot be compared. If the EMPID variable in the <strong>SAS</strong> data set is defined asCHAR(20) and the EMPID column in the DBMS table is defined as DECIMAL(20), youcan use DB<strong>SAS</strong>TYPE= to make them match:proc append base=dblib.hrdata (dbsastype=(empid=’CHAR(20)’))data=saslib.personnel;run;DB<strong>SAS</strong>TYPE= specifies to <strong>SAS</strong> that the EMPID is defined as a character field oflength 20. When a row is inserted from the <strong>SAS</strong> data set into a DBMS table, the DBMSper<strong>for</strong>ms a conversion of the character field to the DBMS data type DECIMAL(20).

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

Saved successfully!

Ooh no, something went wrong!