简体   繁体   中英

Importing Teradata table with surrogate key in sas

I am trying to import a Teradata table from SAS. The teradata table has 21 digit surrogate keys. When i import it from SAS, the surrogate key column gets imported in the form 2.011E12145, however its actual value is a 21 digit number. I tried the following code

Data chk;
format p_key $30.;
set chk;
p_key=surrogate;
run;

But this did not work?

How to avoid this situation and import it in numeric form?

Note that the biggest integer that SAS can accurately store is 2^53-1 (recalling from memory) which would be 9,007,199,254,740,990 (16 digits long). However Teradata supports digits upto 2^64-1 (BigInt data type) which is considerably bigger than what SAS does.

I suspect your SAS-Teradata access is set-up to automatically convert BigInt types to float in SAS which causes the loss of precision.

See http://support.sas.com/kb/39/831.html .

The only other solution I can see is to import the 21-digit key as a character type. You can do this by converting the BigInt into a char data type inside a view in Teradata. (see other ways of doing it in the above link)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM