This example creates a Teradata
table and assigns the SAS TIME8. format to the TRXTIME0 column. Teradata
creates the TRXTIME0 column as the equivalent Teradata data type,
TIME(0), with the value of 12:30:55.
libname mylib teradata user=testuser password=testpass;
data mylib.trxtimes;
format trxtime0 time8.;
trxtime0 = '12:30:55't;
run;
This example creates
a Teradata column that specifies very precise time values. The format
TIME(5) is specified for the TRXTIME5 column. When SAS reads this
column, it assigns the equivalent SAS format TIME14.5.
libname mylib teradata user=testuser password=testpass;
proc sql noerrorstop;
connect to teradata (user=testuser password=testpass);
execute (create table trxtimes (trxtime5 time(5)
)) by teradata;
execute (commit) by teradata;
execute (insert into trxtimes
values (cast('12:12:12' as time(5))
)) by teradata;
execute (commit) by teradata;
quit;
/* You can print the value that is read with SAS/ACCESS. */
proc print data =mylib.trxtimes;
run;
SAS might not preserve
more than four digits of fractional precision for Teradata TIMESTAMP.
This next example creates
a Teradata table and specifies a simple timestamp column with no digits
of precision. Teradata stores the value 2000-01-01 00:00:00. SAS assigns
the default format DATETIME19. to the TRSTAMP0 column generating the
corresponding SAS value of 01JAN2000:00:00:00.
proc sql noerrorstop;
connect to teradata (user=testuser password=testpass);
execute (create table stamps (tstamp0 timestamp(0)
)) by teradata;
execute (commit) by teradata;
execute (insert into stamps
values (cast('2000–01–01 00:00:00' as
timestamp(0))
)) by teradata;
execute (commit) by teradata;
quit;
This example creates
a Teradata table and assigns the SAS format DATETIME23.3 to the TSTAMP3
column, generating the value 13APR1961:12:30:55.123. Teradata creates
the TSTAMP3 column as the equivalent data type TIMESTAMP(3) with the
value 1961-04-13 12:30:55.123.
libname mylib teradata user=testuser password=testpass;
data mylib.stamps;
format tstamp3 datetime23.3;
tstamp3 = '13apr1961:12:30:55.123'dt;
run;
This next example illustrates
how the SAS engine passes the literal value for TIMESTAMP in a WHERE
statement to Teradata for processing. Note that the value is passed
without being rounded or truncated so that Teradata can handle the
rounding or truncation during processing. This example would also
work in a DATA step.
proc sql ;
select * from trlib.flytime where col1 = '22Aug1995 12:30:00.557'dt ;
quit;
In SAS 8, the Teradata
interface did not create TIME and TIMESTAMP data types. Instead, the
interface generated FLOAT values for SAS times and dates. This example
shows how to format a column that contains a FLOAT representation
of a SAS datetime into a readable SAS datetime.
libname mylib teradata user=testuser password=testpass;
proc print data=mylib.stampv80;
format stamp080 datetime25.0;
run;
Here, the old Teradata table STAMPV80 contains
the FLOAT column, STAMP080, which stores SAS datetime values. The
FORMAT statement displays the FLOAT as a SAS datetime value.