|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 11/20/2007 5:15:52 PM
Posts: 1,
Visits: 1
|
|
Does SAS have the capability to explicitly specify a PI as a result of a select statement the way you can in TD?
If you can do this in TD:
CREATE SET TABLE db1.table1 AS
(SELECT name, ssn, address
FROM db2.customers)
WITH DATA
UNIQUE PRIMARY INDEX (ssn);
How do you do that in SAS - or can you?
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 4/1/2008 2:49:57 PM
Posts: 6,
Visits: 44
|
|
Basically, yes. If you are have a connection to a Teradata data source using the SAS LIBNAME mechanism, you can use the "dbcreate_table_opts" SAS data set option to specify any table create option. For example:
libname DB1 teradata user="&terauser" password="&terapass"
schema=DB1 DBCOMMIT=0;
libname DB2 some-other-data-source;
proc sql;
create table DB1.table1(dbcreate_table_opts='primary index(ssn)') as
SELECT name, ssn, address
FROM db2.customers;
quit;
I'd further recommend that you look up the "dbtype" SAS data set option if you choose to do this. That lets you explicitly define the column data types.
Of course, doing it this way only makes sense if your DB2 library is NOT in the same Teradata environment. In other words, if you're creating a Teradata table from a Teradata table, it's much better to use SAS's "pass-thru" facility, with which you can submit normal Teradata SQL:
proc sql;
connect to teradata (user="&terauser" password="&terapass" mode=teradata);
execute ( /* Your original code follows */
CREATE SET TABLE db1.table1 AS
(SELECT name, ssn, address
FROM db2.customers)
WITH DATA
UNIQUE PRIMARY INDEX (ssn)
) by teradata;
quit;
|
|
|
|