Every column in a table has a name and a data type. The data type indicates to the DBMS how much physical storage to reserve for the column and the format in which the data is stored. This section includes information about SAP ASE data types, null values, and data conversions, and also explains how to insert text into SAP ASE from SAS.
SAS/ACCESS does not support these SAP ASE data types: BINARY, VARBINARY, IMAGE, NCHAR(n), and NVARCHAR(n). SAS/ACCESS provides an error message when it tries to read a table that has at least one column that uses an unsupported data type.
Here are the supported SAP ASE data types for SAS/ACCESS Interface to SAP ASE:
| CHAR(n) | TEXT |
| VARCHAR(n) |
| NUMERIC(p,s) | TINYINT |
| DECIMAL(p,s) | SMALLINT |
| REAL | INT |
| FLOAT | BIT |
| DATE | TIMESTAMP |
| TIME | SMALLMONEY |
| SMALLDATETIME | MONEY |
| DATETIME |
You can supplement the
SAP ASE system data types by specifying your own data types with the
SAP ASE system procedure sp_addtype. When
you specify your own data type for a column, you can specify a default
value (other than NULL) for it and specify a range of allowable values
for it.
SAP ASE has a special value that is called NULL. A This value indicates an absence of information and is analogous to a SAS missing value. When SAS/ACCESS reads an SAP ASE NULL value, it interprets it as a SAS missing value.
By default, SAP ASE columns are specified as NOT NULL. NOT NULL tells SAP ASE not to add a row to the table unless the row has a value for the specified column.
If you want a column to accept NULL values, you must explicitly specify it as NULL. Here is an example of a CREATE TABLE statement that specifies all table columns as NULL except CUSTOMER. In this case, SAP ASE accepts a row only if it contains a value for CUSTOMER.
create table CUSTOMERS
(CUSTOMER char(8) not null,
STATE char(2) null,
ZIPCODE char(5) null,
COUNTRY char(20) null,
TELEPHONE char(12) null,
NAME char(60) null,
CONTACT char(30) null,
STREETADDRESS char(40) null,
CITY char(25) null,
FIRSTORDERDATE datetime null);
When you create an SAP ASE table with SAS/ACCESS, you can use the DBNULL= data set option to indicate whether NULL is a valid value for specified columns.
For more information about how SAS handles NULL values, see Potential Result Set Differences When Processing Null Data.
To control how SAS missing character values are handled, use the NULLCHAR= and NULLCHARVAL= data set options.
This table shows the default formats that SAS/ACCESS Interface to SAP ASE assigns to SAS variables when using the LIBNAME statement to read from an SAP ASE table. These default formats are based on SAP ASE column attributes.
|
SAP ASE Column Type |
SAS Data Type |
Default SAS Format |
|---|---|---|
|
CHAR(n ) |
character |
$n2 |
|
VARCHAR(n ) |
character |
$n2 |
|
TEXT |
character |
$n.2 (where n is the value of the DBMAX_TEXT= option) |
|
BIT |
numeric |
1.0 |
|
TINYINT |
numeric |
4.0 |
|
SMALLINT |
numeric |
6.0 |
|
INT |
numeric |
11.0 |
|
NUMERIC |
numeric |
w, w.d (if possible) |
|
DECIMAL |
numeric |
w, w.d (if possible) |
|
FLOAT |
numeric |
BEST22. |
|
REAL |
numeric |
BEST11. |
|
SMALLMONEY |
numeric |
DOLLAR12.2 |
|
MONEY |
numeric |
DOLLAR24.2 |
|
DATE1 |
numeric |
DATE9. |
|
TIME1 |
numeric |
TIME12. |
|
SMALLDATETIME |
numeric |
DATETIME22.3 |
|
DATETIME |
numeric |
DATETIME22.3 |
|
TIMESTAMP |
hexadecimal |
$HEXw |
| 1 If a conflict might occur between the SAP ASE and SAS value for this data type, use SASDATEFMT= to specify the SAS format. | ||
| 2 n specifies the current value for the Adaptive Server page size. | ||
This table shows the default SAP ASE data types that SAS/ACCESS assigns to SAS variable formats during output operations when you use the LIBNAME statement.
|
SAS Variable Format |
SAP ASE Data Type |
|---|---|
|
$w., $CHARw, $VARYINGw., $HEXw. |
VARCHAR(w) |
|
DOLLARw.d |
SMALLMONEY (where w < 6) MONEY (where w >= 6) |
|
datetime format |
DATETIME |
|
date format |
DATE |
|
time format |
TIME |
|
any numeric with a SAS format name of w.d (where d > 0 and w > 10) or w. |
NUMERIC(p,s) |
|
any numeric with a SAS format name of w.d (where d = 0 and w < 10) |
TINYINT (where w < 3) SMALLINT (where w < 5) INT (where w < 10) |
|
any other numeric |
FLOAT |
You can override these default data types by using the DBTYPE= data set option.
This table shows the default SAS variable formats that SAS/ACCESS assigns to SAP ASE data types when you use the ACCESS procedure.
|
SAP ASE Column Type |
SAS Data Type |
Default SAS Format |
|---|---|---|
|
CHAR(n ) |
character |
$n. (n <= 200) $200. (n > 200) |
|
VARCHAR(n ) |
character |
$n. (n <= 200) $200. (n > 200) |
|
BIT |
numeric |
1.0 |
|
TINYINT |
numeric |
4.0 |
|
SMALLINT |
numeric |
6.0 |
|
INT |
numeric |
11.0 |
|
FLOAT |
numeric |
BEST22. |
|
REAL |
numeric |
BEST11. |
|
SMALLMONEY |
numeric |
DOLLAR12.2 |
|
MONEY |
numeric |
DOLLAR24.2 |
|
SMALLDATETIME |
numeric |
DATETIME21.2 |
|
DATETIME |
numeric |
DATETIME21.2 |
The ACCESS procedure also supports SAP ASE user-defined data types. The ACCESS procedure uses the SAP ASE data type on which a user-defined data type is based in order to assign a default SAS format for columns.
The DECIMAL, NUMERIC, and TEXT data types are not supported in PROC ACCESS. The TIMESTAMP data type is not displayed in PROC ACCESS.
This table shows the default SAP ASE data types that SAS/ACCESS assigns to SAS variable formats when you use the DBLOAD procedure.
|
SAS Variable Format |
SAP ASE Data Type |
|---|---|
|
$w., $CHARw., $VARYINGw., $HEXw. |
CHAR(w) |
|
w. |
TINYINT |
|
w. |
SMALLINT |
|
w. |
INT |
|
w. |
FLOAT |
|
w.d |
FLOAT |
|
IBw.d, PIBw.d |
INT |
|
FRACT, E format, and other numeric formats |
FLOAT |
|
DOLLARw.d, w<=12 |
SMALLMONEY |
|
DOLLARw.d, w>12 |
MONEY |
|
any datetime, date, or time format |
DATETIME |
The DBLOAD procedure also supports SAP ASE user-defined data types. Use the TYPE= statement to specify a user-defined data type.
You can insert only TEXT data into an SAP ASE table by using the BULKLOAD= data set option, as in this example:
data yourlib.newtable(bulkload=yes);
set work.sasbigtext;
run;
If you do not use the BULKLOAD= option, you receive this error message:
ERROR: Object not found in database. Error Code: -2782 An untyped variable in the PREPARE statement 'S401bcf78' is being resolved to a TEXT or IMAGE type. This is illegal in a dynamic PREPARE statement.