![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS ODBC Driver User's Guide and Programmer's Reference |
Internally, the SAS System supports two data types for storing data:
| CHAR | fixed-length character data, 200-character maximum |
| NUM | double-precision floating-point number |
For information about user-specified SQL options that can also affect data type representations, see User-Specified SQL Options. For more information about SAS formats, see SAS Language Reference: Dictionary.
| Data Types Reported on Queries |
However, the SAS System stores dates and times as numbers, and the SAS ODBC driver uses SAS format information to infer the following additional SQL data types from NUM data types:(footnote 1)
| SAS Data Type | SQL Data Type |
|---|---|
| NUM FORMAT=DATEn. | SQL_DATE |
| NUM FORMAT=TIMEn. | SQL_TIME |
| NUM FORMAT=DATETIMEn. | SQL_TIMESTAMP |
| Creating or Comparing Date, Time, and Datetime Values |
Both ODBC and SAS date, time and datetime literals are supported by the SAS ODBC driver.
![[cautend]](../common/images/cautend.gif)
select * where hiredate = {d'1995-01-02'}
or
select * where hiredate = '02jan1995'd
Instead, use a datetime literal such as
select * where hiredate = {ts'1995-01-02 00:00:00'}
or
select * where hiredate = '02jan1995:00:00:00'dt
| Interpretation of Data Types in CREATE TABLE Requests |
In a CREATE TABLE statement, any FORMAT= specification
is passed on to the SAS System unmodified, so a column within a table (or
data set) can be created according to any exact specification that is required
for its use within SAS. For example, in the following CREATE TABLE statement,
variable
B's data type and format are passed directly to the
SAS System.
CREATE TABLE
SASUSER.TABLE1
(A INTEGER,
B NUM FORMAT=9.5,
C CHAR(40) );
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.