08-10-2017 08:18 AM
Below code is auto converting value 9d10 to 9e10.It is an account id column loaded into sas from TD.In TD the value is 9d10 whereas in SAS 9E100.
In test dataset the value of x is shown as 9e10.Anybody has any thoughts on why this happens?
Thanks in advance!
08-10-2017 08:25 AM
The reason is that the variable X, for which you supply no information, is being created as length 8 numeric variable. Now 9d10 can be a number and can be represented as 9e10, or 9 to 10 places. You have not said what you want the variable to be? Maybe character (even if not, it is always good to state what type and length your varaibles are):
data test; length x $20; x="9d10"; run;
08-11-2017 03:07 AM
Actually the data for account id is wrong in the source file itself.It should be a numeric value but is coming as a character.
More on teh background:
An XML file line is fed into a column in teradata table(used as source to SAS dataset).
In SAS that column is parsed using a macro and ACOOUNT value in xml is assigned to numeric variable ACCOUNT.
But the xml data 9d100 in TD is converted to 9e100 in sas and we are having question on why the difference in value.
My question is what is the logic behind 9d100 being converted to 9e100 as we need to explain why the value is difefrent.
ACCOUNT column cannot be converted to character as it is inherently numeric.When there is a invalid value it should be same in Teradata and source ideally.
08-11-2017 03:15 AM
Use the notdigit() function on a substring to determine if it's truly numeric before converting.
The .D... notation is mentioned in the 9.2 documentation for the Ew.d informat (which is just an alias for w.d in 9.4) as a valid numeric notation.
08-11-2017 09:09 PM - edited 08-11-2017 09:20 PM
I do not understand your question. The numbers 9e100 and 9d100 are the same number. They both mean 9 times 10 raised to the 100th power. In the old days of Fortran they used the D instead of the E to mean to use double precision (8 byte) floating point instead of single precision (4 bytes). But in SAS all numbers are stored in 8 byte floating point.
If the field is an ACCOUNT number then you should probably be treating it as a character string in SAS. You will never need to take the mean of an ACCOUNT number. Also there is a limit to the number of digits that an 8 byte floating point number can represent exactly.
1 data _null_; 2 x=constant('exactint'); 3 put x comma24. ; 4 run; 9,007,199,254,740,992
08-10-2017 08:27 AM